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

Temporary variable written as field in static block with -Ainfer #3442

Closed
jwaataja opened this issue Jul 7, 2020 · 0 comments · Fixed by #3450
Closed

Temporary variable written as field in static block with -Ainfer #3442

jwaataja opened this issue Jul 7, 2020 · 0 comments · Fixed by #3450
Assignees

Comments

@jwaataja
Copy link
Contributor

jwaataja commented Jul 7, 2020

When the increment operator is used inside of a Java static block, a temporary variable (which I believe is create by this line) is recorded as a field and written out to stub/jaif files with -Ainfer.

With this class

public class TempVars {
    static {
        int i = 0;
        i++;
    }
}

and this command

$CHECKERFRAMEWORK/checker/bin/javac -processor NullnessChecker -Ainfer=stubs TempVars.java

the generated stub file looks like

import org.checkerframework.checker.initialization.qual.Initialized;
import org.checkerframework.checker.nullness.qual.NonNull;

class TempVars {

  // fields:

  @Initialized @NonNull int tempPostfix#num0;

}

This class has no fields but there's a variable tempPostfix written under fields.

This also happens with jaif files, but with those it causes a crash.

Output for

$CHECKERFRAMEWORK/checker/bin/javac -processor NullnessChecker -Ainfer=stubs TempVars.java -version -verbose -AprintAllQualifiers

javac_temp_vars.txt

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 a pull request may close this issue.

2 participants