Skip to content
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

add IT to show a checker errors affects EFFECTIVELY_FINAL in subsequent source files #1

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

XN137
Copy link
Owner

@XN137 XN137 commented Sep 30, 2024

checkerBugGood passes and its output always shows flags like this:

sources files: /GenericException.java, /Violation.java, /SpecialException.java
message1 (effectivelyFinal: true, flags: 2207613190144)
args1 (effectivelyFinal: true, flags: 2224793059328)
x (effectivelyFinal: true, flags: 2199023517696)
x (effectivelyFinal: true, flags: 2199023517696)
x (effectivelyFinal: true, flags: 2199023517696)
x (effectivelyFinal: true, flags: 2199023517696)
message2 (effectivelyFinal: true, flags: 2207613190144)
args2 (effectivelyFinal: true, flags: 2224793059328)
message2 (effectivelyFinal: true, flags: 2207613190144)

checkerBugBad1 fails with:

expected not to contain:
    : [FormatStringAnnotation]
but was:
    [/Violation.java:4: error: [UnusedVariable] The local variable 'x' is never read.
        int x = 0;
            ^
        (see https://errorprone.info/bugpattern/UnusedVariable)
      Did you mean to remove this line?, /SpecialException.java:6: error: [FormatStringAnnotation] All variables passed as @FormatString must be final or effectively final
        super(message2, args2);
             ^
        (see https://errorprone.info/bugpattern/FormatStringAnnotation)]

and output:

sources files: /GenericException.java, /Violation.java, /SpecialException.java
message1 (effectivelyFinal: true, flags: 2207613190144)
args1 (effectivelyFinal: true, flags: 2224793059328)
x (effectivelyFinal: true, flags: 2199023517696)
x (effectivelyFinal: true, flags: 2199023517696)
x (effectivelyFinal: true, flags: 2199023517696)
x (effectivelyFinal: true, flags: 2199023517696)
message2 (effectivelyFinal: false, flags: 8589934592)
args2 (effectivelyFinal: false, flags: 25769803776)
message2 (effectivelyFinal: false, flags: 8589934592)

note how message1 from GenericException.java has the same flags as usual, but message2 from SpecialException.java is no longer effectively final... because it comes after Violation.java ?

checkerBugBad2 fails with output:

sources files: /Violation.java, /GenericException.java, /SpecialException.java
x (effectivelyFinal: true, flags: 2199023517696)
x (effectivelyFinal: true, flags: 2199023517696)
x (effectivelyFinal: true, flags: 2199023517696)
x (effectivelyFinal: true, flags: 2199023517696)
message1 (effectivelyFinal: false, flags: 8589934592)
args1 (effectivelyFinal: false, flags: 25769803776)
message2 (effectivelyFinal: false, flags: 8589934592)
args2 (effectivelyFinal: false, flags: 25769803776)
message2 (effectivelyFinal: false, flags: 8589934592)

note how now both message1 from GenericException.java and message2 from SpecialException.java are no longer effectively final... because they both come after Violation.java ?

checkerBugBad3 fails with output:

sources files: /Violation.java, /SpecialException.java, /GenericException.java
x (effectivelyFinal: true, flags: 2199023517696)
x (effectivelyFinal: true, flags: 2199023517696)
x (effectivelyFinal: true, flags: 2199023517696)
x (effectivelyFinal: true, flags: 2199023517696)
message2 (effectivelyFinal: false, flags: 8589934592)
args2 (effectivelyFinal: false, flags: 25769803776)
message2 (effectivelyFinal: false, flags: 8589934592)
message1 (effectivelyFinal: false, flags: 8589934592)
args1 (effectivelyFinal: false, flags: 25769803776)

same flags as for checkerBugBad2

reproduced in jdks:

openjdk version "17.0.12" 2024-07-16 LTS
OpenJDK Runtime Environment Zulu17.52+17-CA (build 17.0.12+7-LTS)
OpenJDK 64-Bit Server VM Zulu17.52+17-CA (build 17.0.12+7-LTS, mixed mode, sharing)

and

openjdk version "21.0.4" 2024-07-16 LTS
OpenJDK Runtime Environment Zulu21.36+17-CA (build 21.0.4+7-LTS)
OpenJDK 64-Bit Server VM Zulu21.36+17-CA (build 21.0.4+7-LTS, mixed mode, sharing)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant