typetools / checker-framework

Pluggable type-checking for Java
http://checkerframework.org/
Other
1.02k stars 354 forks source link

NPE issue on JDK 17 #5787

Closed beikov closed 1 year ago

beikov commented 1 year ago

I'm using the checker-framework 3.32 through the Gradle plugin version 0.6.25 and we are seeing a NPE when running on JDK 17:

Caused by: java.lang.NullPointerException: Cannot invoke "java.util.TreeSet.clear()" because "this.messageStore" is null
    at org.checkerframework.common.basetype.BaseTypeChecker.typeProcess(BaseTypeChecker.java:537)
    at org.checkerframework.javacutil.AbstractTypeProcessor$AttributionTaskListener.finished(AbstractTypeProcessor.java:188)
    at jdk.compiler/com.sun.tools.javac.api.ClientCodeWrapper$WrappedTaskListener.finished(ClientCodeWrapper.java:854)
    at jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:132)
    at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1394)
    at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1351)
    at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:946)
    at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
    at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.invocationHelper(JavacTaskImpl.java:152)
    ... 31 more

The repository is https://github.com/hibernate/hibernate-orm and we run with the following config:

checkerFramework {
    checkers = [
            'org.checkerframework.checker.nullness.NullnessChecker'
    ]
    extraJavacArgs = [
            '-AsuppressWarnings=initialization',
            "-Astubs=${project.rootDir}/checkerstubs",
            '-AonlyDefs=^org\\.hibernate\\.jpamodelgen\\.'
    ]
}

I expect it to work just like with JDK 11. Any idea what the reason for this could be? No checker should run for that compile task as the onlyDefs config applies for packages of a different gradle module.

beikov commented 1 year ago

Any ideas what is going on here?

smillst commented 1 year ago

I can't tell what's going on from this exception. Can you tell me how to reproduce the exception? Is it only happening on JDK 17?

beikov commented 1 year ago
  1. Checkout the Git repository https://github.com/hibernate/hibernate-orm
  2. Make sure your JAVA_HOME points to a JDK 11
  3. Run the build with ./gradlew :hibernate-core:compileTestJava17Java -Ptest.jdk.version=17 -Porg.gradle.java.installations.paths=<JDK_11_HOME>,<JDK_17_HOME>

The first time might take some time, but subsequent runs will be faster.

beikov commented 1 year ago

Ok, it seems this is a problem of the Gradle plugin. It didn't add the compileOnly dependency to the compile task.