eisop / checker-framework

Pluggable type-checking for Java
https://eisop.github.io/
Other
19 stars 19 forks source link

-Awarns flag causes exception #910

Open renannprado opened 2 months ago

renannprado commented 2 months ago

I'm trying to setup eisop checker framework in a maven multi-module project.

When I add the -Awarns flag, I see that maven logs those as warnings, however the build finishes with error (i.e from my POV an exception).

You can find all relevant information below:

Maven configuration:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <fork>true</fork> <!-- Must fork or else JVM arguments are ignored. -->
        <annotationProcessorPaths>
            <path>
                <groupId>io.github.eisop</groupId>
                <artifactId>checker</artifactId>
                <version>3.42.0-eisop4</version>
            </path>
        </annotationProcessorPaths>
        <annotationProcessors>
            <!-- Add all the checkers you want to enable here -->
            <annotationProcessor>org.checkerframework.checker.nullness.NullnessChecker</annotationProcessor>
        </annotationProcessors>
        <compilerArgs combine.children=" ">
            <arg>-Awarns</arg> <------------ this causes the error
            <arg>-Xmaxerrs</arg>
            <arg>10000</arg>
            <arg>-Xmaxwarns</arg>
            <arg>10000</arg>
            <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</arg>
            <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
            <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
            <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
            <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg>
            <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg>
            <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
            <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
            <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg>
        </compilerArgs>
    </configuration>
</plugin>

Command:

./mvnw clean package -DskipTests -Pchecker

Maven/Java version:

Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)
Maven home: /Users/r.prado/.m2/wrapper/dists/apache-maven-3.9.9/3477a4f1
Java version: 21.0.4, vendor: Eclipse Adoptium, runtime: /Users/r.prado/.sdkman/candidates/java/21.0.4-tem
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "14.6.1", arch: "aarch64", family: "mac"

Output:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:testCompile (default-testCompile) on project user-preference-http-api: Compilation failure
[ERROR] error: Error when invoking constructor org.checkerframework.checker.nullness.KeyForAnnotatedTypeFactory(class org.checkerframework.common.basetype.BaseTypeChecker) on args [org.checkerframework.checker.nullness.KeyForSubchecker@71c27ee8]; cause: TreeUtils.getMethod(org.checkerframework.framework.qual.DefaultQualifier, applyToSubpackages, 0): expected 1 match, found 0: []

Expectation:

I would expect that no error occurs.

wmdietl commented 2 months ago

Thanks for the report and sorry you're running into an issue.

The -Awarns flag only has an impact when the EISOP CF successfully runs. Here, there is an exception when trying to start, so Maven reports that error.

From the error message, this part TreeUtils.getMethod(org.checkerframework.framework.qual.DefaultQualifier, applyToSubpackages, 0): expected 1 match, found 0: [] leads me to suspect that maybe there is a mismatch in the checker-qual artifact. Is there maybe a dependency on checker-qual that does not use io.github.eisop as groupId?

If that does not solve the issue, could you provide some way to reproduce the issue? If that solves the issue, we can make our code more robust against this problem and also document this. Thanks!