Skip to content

Commit

Permalink
Annotate the new repeat API on StringBuilder and friends.
Browse files Browse the repository at this point in the history
I'm not sure that annotation in `AbstractStringBuilder` matter much, but
I'm not ruling it out that an expression could have that implicit type
if you wrote something like `b ? new StringBuilder() : new
StringBuffer()`. And anyway, it was nice to keep `AbstractStringBuilder`
up to date while having reference to its implementation so that I could
then easily cross-reference between it and the subclasses.
  • Loading branch information
cpovirk committed Oct 4, 2024
1 parent cbe846f commit 6035b45
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1964,7 +1964,7 @@ public AbstractStringBuilder repeat(int codePoint, int count) {
*
* @since 21
*/
public AbstractStringBuilder repeat(CharSequence cs, int count) {
public AbstractStringBuilder repeat(@Nullable CharSequence cs, int count) {
if (count < 0) {
throw new IllegalArgumentException("count is negative: " + count);
} else if (count == 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/java.base/share/classes/java/lang/StringBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ public synchronized StringBuffer repeat(int codePoint, int count) {
* @since 21
*/
@Override
public synchronized StringBuffer repeat(CharSequence cs, int count) {
public synchronized StringBuffer repeat(@Nullable CharSequence cs, int count) {
toStringCache = null;
super.repeat(cs, count);
return this;
Expand Down
2 changes: 1 addition & 1 deletion src/java.base/share/classes/java/lang/StringBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ public StringBuilder repeat(int codePoint, int count) {
* @since 21
*/
@Override
public StringBuilder repeat(CharSequence cs, int count) {
public StringBuilder repeat(@Nullable CharSequence cs, int count) {
super.repeat(cs, count);
return this;
}
Expand Down

0 comments on commit 6035b45

Please sign in to comment.