Skip to content

Commit

Permalink
Add @Nullable annotations to join and formatted.
Browse files Browse the repository at this point in the history
For `join`, compare jspecify/jdk#111.

I might have done `formatted` during a mega-merge? I don't remember
offhand. Anyway, it makes sense for it to match `format`.
  • Loading branch information
cpovirk committed Jan 6, 2025
1 parent 2a5380e commit 1919bcc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/java.base/share/classes/java/lang/String.java
Original file line number Diff line number Diff line change
Expand Up @@ -3379,7 +3379,7 @@ public String replace(@GuardSatisfied CharSequence target, @GuardSatisfied CharS
*/
@SideEffectFree
@StaticallyExecutable
public static String join(CharSequence delimiter, CharSequence... elements) {
public static String join(CharSequence delimiter, @Nullable CharSequence... elements) {
var delim = delimiter.toString();
var elems = new String[elements.length];
for (int i = 0; i < elements.length; i++) {
Expand Down Expand Up @@ -3475,7 +3475,7 @@ static String join(String prefix, String suffix, String delimiter, String[] elem
@SideEffectFree
@StaticallyExecutable
public static String join(CharSequence delimiter,
Iterable<? extends CharSequence> elements) {
Iterable<? extends @Nullable CharSequence> elements) {
Objects.requireNonNull(delimiter);
Objects.requireNonNull(elements);
var delim = delimiter.toString();
Expand Down Expand Up @@ -4393,7 +4393,7 @@ public static String format(@GuardSatisfied @Nullable Locale l, String format, @
*
*/
@SideEffectFree
public String formatted(Object... args) {
public String formatted(@Nullable Object... args) {
return new Formatter().format(this, args).toString();
}

Expand Down

0 comments on commit 1919bcc

Please sign in to comment.