Skip to content

Commit

Permalink
Use lowercase message keys for consistency (#3909)
Browse files Browse the repository at this point in the history
Fixes #3908.
  • Loading branch information
mernst authored Nov 18, 2020
1 parent 062e0b2 commit 76cc288
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions checker/jtreg/nullness/issue1929/Issue1929-notrust.out
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Issue1929.java:21:25: compiler.err.proc.messager: [return.type.incompatible] incompatible types in return.
type of expression: @Initialized @Nullable String @Initialized @NonNull []
method return type: @Initialized @NonNull String @Initialized @NonNull []
Issue1929.java:21:25: compiler.warn.proc.messager: [toArray.nullable.elements.not.newarray] call of toArray on collection of non-null elements yields an array of possibly-null elements; omit the argument to toArray or make it an explicit array constructor
Issue1929.java:21:25: compiler.warn.proc.messager: [toarray.nullable.elements.not.newarray] call of toArray on collection of non-null elements yields an array of possibly-null elements; omit the argument to toArray or make it an explicit array constructor
Issue1929.java:29:25: compiler.err.proc.messager: [return.type.incompatible] incompatible types in return.
type of expression: @Initialized @Nullable String @Initialized @NonNull []
method return type: @Initialized @NonNull String @Initialized @NonNull []
Issue1929.java:29:25: compiler.warn.proc.messager: [toArray.nullable.elements.not.newarray] call of toArray on collection of non-null elements yields an array of possibly-null elements; omit the argument to toArray or make it an explicit array constructor
Issue1929.java:29:25: compiler.warn.proc.messager: [toarray.nullable.elements.not.newarray] call of toArray on collection of non-null elements yields an array of possibly-null elements; omit the argument to toArray or make it an explicit array constructor
2 errors
2 warnings
2 changes: 1 addition & 1 deletion checker/jtreg/nullness/issue1929/Issue1929-trust.out
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Issue1929.java:29:25: compiler.err.proc.messager: [return.type.incompatible] incompatible types in return.
type of expression: @Initialized @Nullable String @Initialized @NonNull []
method return type: @Initialized @NonNull String @Initialized @NonNull []
Issue1929.java:29:25: compiler.warn.proc.messager: [toArray.nullable.elements.not.newarray] call of toArray on collection of non-null elements yields an array of possibly-null elements; omit the argument to toArray or make it an explicit array constructor
Issue1929.java:29:25: compiler.warn.proc.messager: [toarray.nullable.elements.not.newarray] call of toArray on collection of non-null elements yields an array of possibly-null elements; omit the argument to toArray or make it an explicit array constructor
1 error
1 warning
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ public void handle(MethodInvocationTree tree, AnnotatedExecutableType method) {

if (receiverIsNonNull && !argIsHandled) {
if (argument.getKind() != Tree.Kind.NEW_ARRAY) {
checker.reportWarning(tree, "toArray.nullable.elements.not.newarray");
checker.reportWarning(tree, "toarray.nullable.elements.not.newarray");
} else {
checker.reportWarning(tree, "toArray.nullable.elements.mismatched.size");
checker.reportWarning(tree, "toarray.nullable.elements.mismatched.size");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class.not.found.nullness.parse.error=class not found for field "%s"
field.not.found.nullness.parse.error=field "%s" not found
new.array.type.invalid=annotations %s may not be applied as component type for array "%s"
new.class.type.invalid=the annotations %s do not need be applied in object creations
toArray.nullable.elements.not.newarray=call of toArray on collection of non-null elements yields an array of possibly-null elements; omit the argument to toArray or make it an explicit array constructor
toArray.nullable.elements.mismatched.size=call of toArray on collection of non-null elements yields an array of possibly-null elements; cannot determine that the argument array has the same size as the receiver collection
toarray.nullable.elements.not.newarray=call of toArray on collection of non-null elements yields an array of possibly-null elements; omit the argument to toArray or make it an explicit array constructor
toarray.nullable.elements.mismatched.size=call of toArray on collection of non-null elements yields an array of possibly-null elements; cannot determine that the argument array has the same size as the receiver collection
clear.system.property=call might clear a predefined system property; pass -Alint=permitClearProperty to permit it
instanceof.nullable=instanceof is only true for a non-null expression
instanceof.nonnull.redundant=redundant @NonNull annotation on instanceof
Expand Down
4 changes: 2 additions & 2 deletions checker/tests/nullness/ToArrayDiagnostics.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ String[] ok4(ArrayList<String> list) {
String[] warn1(ArrayList<String> list) {
// :: error: (new.array.type.invalid)
String[] resultArray = new String[list.size()];
// :: error: (return.type.incompatible) :: warning: (toArray.nullable.elements.not.newarray)
// :: error: (return.type.incompatible) :: warning: (toarray.nullable.elements.not.newarray)
return list.toArray(resultArray);
}

String[] warn2(ArrayList<String> list) {
int size = list.size();
// :: error: (new.array.type.invalid) :: error: (return.type.incompatible) :: warning:
// (toArray.nullable.elements.mismatched.size)
// (toarray.nullable.elements.mismatched.size)
return list.toArray(new String[size]);
}
}
16 changes: 8 additions & 8 deletions checker/tests/nullness/ToArrayNullness.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,36 +72,36 @@ void testHearusitics() {
for (@Nullable String o : nonnullCol.toArray(new String[nonnullCol.size()])) ;
for (@NonNull String o : nonnullCol.toArray(new String[nonnullCol.size()])) ;

// :: warning: (toArray.nullable.elements.mismatched.size)
// :: warning: (toarray.nullable.elements.mismatched.size)
for (@Nullable String o : nonnullCol.toArray(new @Nullable String[] {null})) ;
// :: error: (enhancedfor.type.incompatible) :: warning:
// (toArray.nullable.elements.mismatched.size)
// (toarray.nullable.elements.mismatched.size)
for (@NonNull String o : nonnullCol.toArray(new @Nullable String[] {null})) ; // error
// Size 1 is too big for an empty array. Complain. TODO: Could allow as result is Nullable.
// :: error: (new.array.type.invalid) :: warning:
// (toArray.nullable.elements.mismatched.size)
// (toarray.nullable.elements.mismatched.size)
for (@Nullable String o : nonnullCol.toArray(new String[1])) ;
// :: error: (enhancedfor.type.incompatible) :: error: (new.array.type.invalid) :: warning:
// (toArray.nullable.elements.mismatched.size)
// (toarray.nullable.elements.mismatched.size)
for (@NonNull String o : nonnullCol.toArray(new String[1])) ; // error
// Array too big -> complain. TODO: Could allow as result is Nullable.
// :: error: (new.array.type.invalid) :: warning:
// (toArray.nullable.elements.mismatched.size)
// (toarray.nullable.elements.mismatched.size)
for (@Nullable String o : nonnullCol.toArray(new String[nonnullCol.size() + 1])) ;
// Array too big -> complain.
// :: error: (enhancedfor.type.incompatible) :: error: (new.array.type.invalid) :: warning:
// (toArray.nullable.elements.mismatched.size)
// (toarray.nullable.elements.mismatched.size)
for (@NonNull String o : nonnullCol.toArray(new String[nonnullCol.size() + 1])) ; // error

// cannot handle the following cases for now
// new array not size 0 or .size -> complain about cration. TODO: Could allow as result is
// Nullable.
// :: error: (new.array.type.invalid) :: warning:
// (toArray.nullable.elements.mismatched.size)
// (toarray.nullable.elements.mismatched.size)
for (@Nullable String o : nonnullCol.toArray(new String[nonnullCol.size() - 1])) ;
// New array not size 0 or .size -> complain about creation.
// :: error: (enhancedfor.type.incompatible) :: error: (new.array.type.invalid) :: warning:
// (toArray.nullable.elements.mismatched.size)
// (toarray.nullable.elements.mismatched.size)
for (@NonNull String o : nonnullCol.toArray(new String[nonnullCol.size() - 1])) ; // error
}
}

0 comments on commit 76cc288

Please sign in to comment.