-
Notifications
You must be signed in to change notification settings - Fork 29
Introduce optimistic default #1386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
5a64e25
964b9b5
6ed19a1
465a585
4e84cfe
c6131d1
740b9b0
edff48e
f512035
254b05e
958a714
0e1e751
1e1ef27
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,24 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
| # set -o verbose | ||
| set -o xtrace | ||
| export SHELLOPTS | ||
| echo "SHELLOPTS=${SHELLOPTS}" | ||
|
|
||
| SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)" | ||
| source "$SCRIPT_DIR"/clone-related.sh | ||
|
|
||
| ./gradlew assembleForJavac --console=plain -Dorg.gradle.internal.http.socketTimeout=60000 -Dorg.gradle.internal.http.connectionTimeout=60000 | ||
|
|
||
| # TODO: remove uses of `main-eisop` once that becomes `main`. | ||
| "$SCRIPT_DIR/.git-scripts/git-clone-related" --upstream-branch main-eisop eisop jspecify-reference-checker | ||
|
|
||
| cd ../jspecify-reference-checker | ||
|
|
||
| # Delete the eisop/jdk that was already cloned... | ||
| rm -r ../jdk | ||
| # instead clone the jspecify/jdk. | ||
| "$SCRIPT_DIR/.git-scripts/git-clone-related" jspecify jdk | ||
|
|
||
| JSPECIFY_CONFORMANCE_TEST_MODE=details ./gradlew build conformanceTests demoTest --console=plain --include-build "$CHECKERFRAMEWORK" | ||
| ##!/bin/bash | ||
| # | ||
| #set -e | ||
| ## set -o verbose | ||
| #set -o xtrace | ||
| #export SHELLOPTS | ||
| #echo "SHELLOPTS=${SHELLOPTS}" | ||
| # | ||
| #SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)" | ||
| #source "$SCRIPT_DIR"/clone-related.sh | ||
| # | ||
| #./gradlew assembleForJavac --console=plain -Dorg.gradle.internal.http.socketTimeout=60000 -Dorg.gradle.internal.http.connectionTimeout=60000 | ||
| # | ||
| ## TODO: remove uses of `main-eisop` once that becomes `main`. | ||
| #"$SCRIPT_DIR/.git-scripts/git-clone-related" --upstream-branch main-eisop eisop jspecify-reference-checker | ||
| # | ||
| #cd ../jspecify-reference-checker | ||
| # | ||
| ## Delete the eisop/jdk that was already cloned... | ||
| #rm -r ../jdk | ||
| ## instead clone the jspecify/jdk. | ||
| #"$SCRIPT_DIR/.git-scripts/git-clone-related" jspecify jdk | ||
| # | ||
| #JSPECIFY_CONFORMANCE_TEST_MODE=details ./gradlew build conformanceTests demoTest --console=plain --include-build "$CHECKERFRAMEWORK" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,14 @@ | ||
| AnnotatedForWithUse.java:27:36: compiler.err.proc.messager: [assignment.type.incompatible] incompatible types in assignment. | ||
| AnnotatedForWithUse.java:28:36: compiler.err.proc.messager: [assignment.type.incompatible] incompatible types in assignment. | ||
| found : @Nullable Object | ||
| required: @NonNull Object | ||
| AnnotatedForWithUse.java:31:18: compiler.err.proc.messager: [dereference.of.nullable] dereference of possibly-null reference u.get() | ||
| AnnotatedForWithUse.java:31:29: compiler.err.proc.messager: [method.invocation.invalid] call to toString() not allowed on the given receiver. | ||
| AnnotatedForWithUse.java:32:18: compiler.err.proc.messager: [dereference.of.nullable] dereference of possibly-null reference u.get() | ||
| AnnotatedForWithUse.java:32:29: compiler.err.proc.messager: [method.invocation.invalid] call to toString() not allowed on the given receiver. | ||
| found : @UnknownInitialization Object | ||
| required: @Initialized Object | ||
| AnnotatedForWithUse.java:33:19: compiler.err.proc.messager: [argument.type.incompatible] incompatible argument for parameter of of Unannotated.set. | ||
| AnnotatedForWithUse.java:34:19: compiler.err.proc.messager: [argument.type.incompatible] incompatible argument for parameter of of Unannotated.set. | ||
| found : @UnknownKeyFor NullType | ||
| required: @KeyForBottom Object | ||
| AnnotatedForWithUse.java:33:19: compiler.err.proc.messager: [argument.type.incompatible] incompatible argument for parameter of of Unannotated.set. | ||
| AnnotatedForWithUse.java:34:19: compiler.err.proc.messager: [argument.type.incompatible] incompatible argument for parameter of of Unannotated.set. | ||
| found : @Nullable NullType | ||
| required: @NonNull Object | ||
| 5 errors |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,11 @@ | ||
| AnnotatedForWithUse.java:14:16: compiler.err.proc.messager: [initialization.field.uninitialized] the default constructor does not initialize field o | ||
| AnnotatedForWithUse.java:17:20: compiler.err.proc.messager: [return.type.incompatible] incompatible types in return. | ||
| AnnotatedForWithUse.java:15:16: compiler.err.proc.messager: [initialization.field.uninitialized] the default constructor does not initialize field o | ||
| AnnotatedForWithUse.java:18:20: compiler.err.proc.messager: [return.type.incompatible] incompatible types in return. | ||
| type of expression: @Nullable NullType | ||
| method return type: @NonNull Object | ||
| AnnotatedForWithUse.java:29:19: compiler.err.proc.messager: [assignment.type.incompatible] incompatible types in assignment. | ||
| AnnotatedForWithUse.java:30:19: compiler.err.proc.messager: [assignment.type.incompatible] incompatible types in assignment. | ||
| found : @Nullable NullType | ||
| required: @NonNull Object | ||
| AnnotatedForWithUse.java:33:19: compiler.err.proc.messager: [argument.type.incompatible] incompatible argument for parameter of of Unannotated.set. | ||
| AnnotatedForWithUse.java:34:19: compiler.err.proc.messager: [argument.type.incompatible] incompatible argument for parameter of of Unannotated.set. | ||
| found : @Nullable NullType | ||
| required: @NonNull Object | ||
| 4 errors |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| AnnotatedForWithUse.java:29:19: compiler.err.proc.messager: [assignment.type.incompatible] incompatible types in assignment. | ||
| AnnotatedForWithUse.java:30:19: compiler.err.proc.messager: [assignment.type.incompatible] incompatible types in assignment. | ||
| found : @Nullable NullType | ||
| required: @NonNull Object | ||
| AnnotatedForWithUse.java:33:19: compiler.err.proc.messager: [argument.type.incompatible] incompatible argument for parameter of of Unannotated.set. | ||
| AnnotatedForWithUse.java:34:19: compiler.err.proc.messager: [argument.type.incompatible] incompatible argument for parameter of of Unannotated.set. | ||
| found : @Nullable NullType | ||
| required: @NonNull Object | ||
| 2 errors |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| AnnotatedForWithUse.java:15:16: compiler.err.proc.messager: [type.invalid.annotations.on.location] annotation @org.checkerframework.checker.nullness.qual.KeyForBottom used on prohibited locations FIELD | ||
| AnnotatedForWithUse.java:15:16: compiler.err.proc.messager: [initialization.field.uninitialized] the default constructor does not initialize field o | ||
| AnnotatedForWithUse.java:15:16: compiler.err.proc.messager: [type.invalid.annotations.on.location] annotation @org.checkerframework.checker.initialization.qual.FBCBottom used on prohibited locations FIELD | ||
| AnnotatedForWithUse.java:17:16: compiler.err.proc.messager: [type.invalid.annotations.on.location] annotation @org.checkerframework.checker.nullness.qual.KeyForBottom used on prohibited locations RETURN | ||
| AnnotatedForWithUse.java:17:16: compiler.err.proc.messager: [type.invalid.annotations.on.location] annotation @org.checkerframework.checker.initialization.qual.FBCBottom used on prohibited locations RETURN | ||
| AnnotatedForWithUse.java:18:20: compiler.err.proc.messager: [return.type.incompatible] incompatible types in return. | ||
| type of expression: @UnknownKeyFor NullType | ||
| method return type: @KeyForBottom Object | ||
| AnnotatedForWithUse.java:18:20: compiler.err.proc.messager: [return.type.incompatible] incompatible types in return. | ||
| type of expression: @Nullable NullType | ||
| method return type: @NonNull Object | ||
| AnnotatedForWithUse.java:30:19: compiler.err.proc.messager: [assignment.type.incompatible] incompatible types in assignment. | ||
| found : @UnknownKeyFor NullType | ||
| required: @KeyForBottom Object | ||
| AnnotatedForWithUse.java:30:19: compiler.err.proc.messager: [assignment.type.incompatible] incompatible types in assignment. | ||
| found : @Nullable NullType | ||
| required: @NonNull Object | ||
| 9 errors |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -204,6 +204,14 @@ | |
| // Whether to type check the enclosing expression of an inner class instantiation. | ||
| "checkEnclosingExpr", | ||
|
|
||
| // Whether to use optimistic defaults for bytecode and/or source code. | ||
| // The option takes same arguments as "useConservativeDefaultsForUncheckedCode". | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ordering of the options should be switched, instead of having a forward reference here. |
||
| // Optimistic default will only apply the code is not in the scope of an @AnnotatedFor. | ||
| // Note using this option will not suppress the warning for source code not in the scope of an | ||
| // @AnnotatedFor, user can use -AonlyAnnotatedFor together with this option. | ||
| // Optimistic and conservative defaults should apply to source or/and bytecode at the same time. | ||
| "useOptimisticDefaultsForUncheckedCode", | ||
|
|
||
| // Whether to use conservative defaults for bytecode and/or source code. | ||
| // This option takes arguments "source" and/or "bytecode". | ||
| // The default is "-source,-bytecode" (eventually this will be changed to "-source,bytecode"). | ||
|
|
@@ -2814,8 +2822,35 @@ public boolean shouldSuppressWarnings(TreePath path, String errKey) { | |
| } | ||
|
|
||
| /** | ||
| * Should conservative defaults be used for the kind of unchecked code indicated by the | ||
| * parameter? | ||
| * Determine whether optimistic defaults should be used for the kind of unchecked code indicated | ||
| * by the command line arguments. | ||
| * | ||
| * @param kindOfCode source or bytecode | ||
| * @return whether optimistic defaults should be used | ||
| */ | ||
| public boolean useOptimisticDefault(String kindOfCode) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lots of duplicated code. |
||
| boolean useUncheckedDefaultsForSource = false; | ||
| boolean useUncheckedDefaultsForByteCode = false; | ||
| for (String arg : this.getStringsOption("useOptimisticDefaultsForUncheckedCode", ',')) { | ||
| boolean value = arg.indexOf("-") != 0; | ||
| arg = value ? arg : arg.substring(1); | ||
| if (arg.equals(kindOfCode)) { | ||
| return value; | ||
| } | ||
| } | ||
| if (kindOfCode.equals("source")) { | ||
| return useUncheckedDefaultsForSource; | ||
| } else if (kindOfCode.equals("bytecode")) { | ||
| return useUncheckedDefaultsForByteCode; | ||
| } else { | ||
| throw new UserError( | ||
| "SourceChecker: unexpected argument to useOptimisticDefault: " + kindOfCode); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Determine whether conservative defaults should be used for the kind of unchecked code | ||
| * indicated by the command line arguments. | ||
| * | ||
| * @param kindOfCode source or bytecode | ||
| * @return whether conservative defaults should be used | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -797,7 +797,7 @@ protected final QualifierDefaults createAndInitQualifierDefaults() { | |
| QualifierDefaults defs = createQualifierDefaults(); | ||
| addCheckedCodeDefaults(defs); | ||
| addCheckedStandardDefaults(defs); | ||
| addUncheckedStandardDefaults(defs); | ||
| addUncheckedDefaults(defs); | ||
| checkForDefaultQualifierInHierarchy(defs); | ||
|
|
||
| return defs; | ||
|
|
@@ -876,12 +876,13 @@ protected void addCheckedStandardDefaults(QualifierDefaults defs) { | |
| } | ||
|
|
||
| /** | ||
| * Adds standard unchecked defaults that do not conflict with previously added defaults. | ||
| * Adds both optimistic and conservative unchecked defaults that do not conflict with previously | ||
| * added defaults. | ||
| * | ||
| * @param defs {@link QualifierDefaults} object to which defaults are added | ||
| */ | ||
| protected void addUncheckedStandardDefaults(QualifierDefaults defs) { | ||
| defs.addUncheckedStandardDefaults(); | ||
| protected void addUncheckedDefaults(QualifierDefaults defs) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why rename this method? It will still set the standard defaults. What changed? |
||
| defs.addUncheckedDefaults(); | ||
| } | ||
|
|
||
| /** | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need to go through the manual and discuss this new option there.