0
votes

-J-Xbootclasspath/p: is not passed by maven compiler plugin,how can I workaround it?

System enviroment: jdk 1.8.0_265,windows 10.
maven file: I copied it from CheckerFramework example pom.xml.

<compilerArgs>
  <!-- using github.com/google/error-prone-javac is required when running on JDK 8 -->
  <arg>-J-Xbootclasspath/p:${errorProneJavac}</arg>
  <!-- -Awarns treats Checker Framework errors as warnings -->
  <!-- <arg>-Awarns</arg> -->
  <!--
    For the Subtyping Checker, annotations defined in module 'your-qual-artifact':
    <arg>-Aquals=myPackage.qual.MyFenum,myPackage.qual.MyCustomType</arg>
  -->
  <arg>-Alint</arg>
  <!-- If using JDK 11 remove the two arguments above and uncomment the one below. -->
  <!-- <arg>-J- -add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg> -->
  <!-- -Awarns turns type-checking errors into warnings. -->
  <!-- <arg>-Awarns</arg> -->
</compilerArgs>

When I first run it by mvn clean compile,it fall with

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project MavenExample: Compilation failure

So I run mvn clean compile -X then found that -J-Xbootclasspath/p:/path/to/javac.jar not included in the command line option.
Then I tred include "-J-Xbootclasspath/p" in and mannualy javac compile it and it successed. But I need use it in maven,so I ask the question.

this is the printed failed command line option

[DEBUG]
-d D:\workproject\TestCheck\target\classes
-classpath D:\workproject\TestCheck\target\classes;C:\Users\张云.m2\repository\org\checkerframework\checker-qual\3.6.1\checker-qual-3.6.1.jar;C:\Users\张云.m2\repository\com\google\errorprone\javac\9+181-r4173-1\javac-9+181-r4173-1.jar;C:\Users\张云.m2\repository\org\apache\commons\commons-lang3\3.1\commons-lang3-3.1.jar;C:\Users\张云.m2\repository\javax\servlet\servlet-api\2.4\servlet-api-2.4.jar;
-sourcepath D:\workproject\TestCheck\src\main\java;D:\workproject\TestCheck\target\generated-sources\annotations; D:\workproject\TestCheck\src\main\java\Main.java -s D:\workproject\TestCheck\target\generated-sources\annotations
-processor org.checkerframework.checker.nullness.NullnessChecker
-processorpath C:\Users\张云.m2\repository\org\checkerframework\checker\3.6.1\checker-3.6.1.jar; -g -verbose -target 1.8 -source 1.8 -encoding UTF-8 -Alint

this is the complete log file log

and project file

1
Could you please provide a complete reproducible example? It should include a complete project, including the full pom.xml file you are using (not just a snippet of it), so that others can reproduce the problem.mernst
@mernst As your request ,I upload the project file.It's just a hello world project and its pom.xml is a copy from the checker framework example pom.xml url.user4390824

1 Answers

0
votes

Thanks for providing the project; that is very helpful.

When I ran mvn -e -B clean install --debug, the Checker Framework worked properly: it issued an error about return null on line 10 of file Main.java:

[ERROR] /home/mernst/tmp/TestCheck/src/main/java/Main.java:[10,15] error: [return.type.incompatible] incompatible types in return.
  type of expression: null
  method return type: @Initialized @NonNull String

The full log is at https://pastebin.com/4kHe4WMz .

There are some suspicious differences between my output and the log that you provided.

My output, when running on the project you provided, contains:

  <compilerArgs>
    <arg>-J-Xbootclasspath/p:${com.google.errorprone:javac:jar}</arg>
    <arg>-Alint</arg>
  </compilerArgs>

By contrast, the log you pasted contains:

  <compilerArgs>
    <arg>-Alint</arg>
  </compilerArgs>
  <compilerArgument>-J-Xbootclasspath/p:/a/b</compilerArgument>

I don't have an explanation for the difference. For example, I don't know where the /a/b path in your output came from, since that doesn't appear in the project you provided. I suspect that you pasted a log from a different project, with a different pom.xml, than the project you provided.