Error-prone: Maven & AutoValue: Crash on openjdk8, Compile error on openjdk11

Created on 11 Feb 2021  Â·  6Comments  Â·  Source: google/error-prone

Description of the problem

After adding ErrorProne to my project as specified on https://errorprone.info/docs/installation by adding this to my pom.xml:

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>
        <configuration>
          <source>8</source>
          <target>8</target>
+          <compilerArgs>
+            <arg>-XDcompilePolicy=simple</arg>
+            <arg>-Xplugin:ErrorProne</arg>
+          </compilerArgs>
+          <annotationProcessorPaths>
+            <path>
+              <groupId>com.google.errorprone</groupId>
+              <artifactId>error_prone_core</artifactId>
+              <version>2.5.1</version>
+            </path>
+          </annotationProcessorPaths>
        </configuration>
      </plugin>

mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V gets me a compiler crash on openjdk8, and a compilation error where @AutoValue generated code isn't found on openjdk11.

See commit here, was part of this PR.

See full errors from Travis CI here

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

$ git clone git://github.com/google/acai
(make above edit)
$ mvn clean package

What version of Error Prone are you using?

2.5.1

Have you found anything relevant by searching the web?

No. Not sure if the problem is Maven, the maven-compiler-plugin version, AutoValue or the error_prone version either.

Most helpful comment

Would it make sense to add explicit mention of the to the Maven section in the doc? I ignored that at the end because I thought it didn't apply, and I didn't need it before.

Good idea, how does https://github.com/google/error-prone/commit/0b8bd1c7b78515d28088b6c3f0570b4bf8a47502 look?

All 6 comments

The error is:

java.lang.RuntimeException: java.lang.NoSuchMethodError: com.sun.tools.javac.util.JavacMessages.add(Lcom/sun/tools/javac/util/JavacMessages$ResourceBundleHelper;)V
    at com.sun.tools.javac.main.Main.compile(Main.java:473)
    at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
    at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)

When running on JDK 8, are you following the JDK 8-specific instructions in http://errorprone.info/docs/installation, in particular the part about passing -J-Xbootclasspath/p:?

Oops sorry — I've now added that part, and the error changes:

[ERROR] /home/travis/build/google/acai/src/main/java/com/google/acai/GuiceberryCompatibilityModule.java:[119,17] error: cannot find symbol
  symbol:   class AutoValue_GuiceberryCompatibilityModule_MethodReference
  location: class MethodReference

So it doesn't crash anymore with JDK 8, and now fails with the missing AutoValue processing in both 8 and 11.

error: cannot find symbol ... AutoValue_...

Did you see the bit about "Using ErrorProne in concert with other Annotation Processors" at the end of http://errorprone.info/docs/installation ?

You likely need to move the dependency on AutoValue to <annotationProcessorPaths>.

Awesome, that fixed it, thank you!

Would it make sense to add explicit mention of the <annotationProcessorPaths> to the Maven section in the doc? I ignored that at the end because I thought it didn't apply, and I didn't need it before.

Would it make sense to add explicit mention of the to the Maven section in the doc? I ignored that at the end because I thought it didn't apply, and I didn't need it before.

Good idea, how does https://github.com/google/error-prone/commit/0b8bd1c7b78515d28088b6c3f0570b4bf8a47502 look?

Looks good, thanks!

Was this page helpful?
0 / 5 - 0 ratings