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

Unable to pass parameter to ErrorProne in Maven with JDK 11 #1136

Closed
ctabin opened this issue Oct 8, 2018 · 3 comments
Closed

Unable to pass parameter to ErrorProne in Maven with JDK 11 #1136

ctabin opened this issue Oct 8, 2018 · 3 comments

Comments

@ctabin
Copy link

ctabin commented Oct 8, 2018

Hello,

We're usine errorprone with the OpenJDK 8 and all works well. Now we're planning to move to OpenJDK 11.
So, we adapted the configuration to the one below:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>3.8.0</version>
  <configuration>
    <release>11</release>
    <compilerArgs>
      <arg>-XDcompilePolicy=simple</arg>
      <arg>-Xplugin:ErrorProne</arg>
      <arg>-Xep:MissingCasesInEnumSwitch:OFF</arg>
      <arg>-Xep:ParameterName:OFF</arg>
      <arg>-Xep:JdkObsolete:WARN</arg>
      <arg>-Xep:BadAnnotationImplementation:ERROR</arg>
      <arg>-Xep:BadComparable:ERROR</arg>
      <arg>-Xep:BigDecimalEquals:ERROR</arg>
      <arg>-Xep:BigIntegerEquals:ERROR</arg>
      <arg>-Xep:CanonicalDuration:ERROR</arg>
      <arg>-Xep:DateEquals:ERROR</arg>
      <arg>-Xep:DivZero:ERROR</arg>
      <arg>-Xep:EmptyIf:ERROR</arg>
      <arg>-Xep:EqualsHashCode:ERROR</arg>
      <arg>-Xep:FloatingPointLiteralPrecision:ERROR</arg>
      <arg>-Xep:JavaLangClash:ERROR</arg>
      <arg>-Xep:MultipleUnaryOperatorsInMethodCall:ERROR</arg>
      <arg>-Xep:NumericEquality:ERROR</arg>
      <arg>-Xep:ObjectToString:ERROR</arg>
      <arg>-Xep:OptionalNotPresent:ERROR</arg>
      <arg>-Xep:ShortCircuitBoolean:ERROR</arg>
      <arg>-Xep:StaticGuardedByInstance:ERROR</arg>
      <arg>-Xep:StaticQualifiedUsingExpression:ERROR</arg>
      <arg>-Xep:StringEquality:ERROR</arg>
      <arg>-Xep:SynchronizeOnNonFinalField:ERROR</arg>
      <arg>-Xep:VarTypeName:ERROR</arg>
    </compilerArgs>
    <annotationProcessorPaths>
      <path>
        <groupId>com.google.errorprone</groupId>
        <artifactId>error_prone_core</artifactId>
        <version>2.3.1</version>
      </path>
    </annotationProcessorPaths>
  </configuration>
</plugin>

But it doesn't even try to compile and output the following error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project BlueIron: Fatal error compiling: error: invalid flag: -Xep:MissingCasesInEnumSwitch:OFF

Note that if I remove all the -Xep: flags, the compilation occurs and fails with the following stacktrace:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.errorprone.util.FindIdentifiers (file:/home/.m2/repository/com/google/errorprone/error_prone_check_api/2.3.1/error_prone_check_api-2.3.1.jar) to method com.sun.tools.javac.comp.Resolve.findIdent(com.sun.tools.javac.comp.Env,com.sun.tools.javac.util.Name,com.sun.tools.javac.code.Kinds$KindSelector)
WARNING: Please consider reporting this to the maintainers of com.google.errorprone.util.FindIdentifiers
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
compiler message file broken: key=compiler.misc.msg.bug arguments=11, {1}, {2}, {3}, {4}, {5}, {6}, {7}
java.lang.NoSuchMethodError: com.sun.tools.javac.util.Log.error(Lcom/sun/tools/javac/util/JCDiagnostic$DiagnosticPosition;Ljava/lang/String;[Ljava/lang/Object;)V
        at com.google.errorprone.ErrorProneError.logFatalError(ErrorProneError.java:55)
        at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:155)
        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:1418)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1365)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:960)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:147)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
        at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:126)
        at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:174)
        at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1129)
        at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:188)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:955)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:290)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:194)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

But that seems related to #1091 (or maybe passing the --illegal-access=warn flag). Or maybe related to the disabled checks above.

Thanks in advance for your help !

@tbroyer
Copy link
Contributor

tbroyer commented Oct 8, 2018

AFAICT, you need to use 2.3.2-SNAPSHOT with JDK 11, but even then, your build would still fail: you need to pass all Error Prone arguments in the same <arg> as -Xplugin:ErrorProne, space (regexp's \s+) separated.

<arg>-Xplugin:ErrorProne
     -Xep:MissingCasesInEnumSwitch:OFF
     -Xep:ParameterName:OFF
     -Xep:JdkObsolete:WARN
     -Xep:BadAnnotationImplementation:ERROR
     -Xep:BadComparable:ERROR
     -Xep:BigDecimalEquals:ERROR
     -Xep:BigIntegerEquals:ERROR
     -Xep:CanonicalDuration:ERROR
     -Xep:DateEquals:ERROR
     -Xep:DivZero:ERROR
     -Xep:EmptyIf:ERROR
     -Xep:EqualsHashCode:ERROR
     -Xep:FloatingPointLiteralPrecision:ERROR
     -Xep:JavaLangClash:ERROR
     -Xep:MultipleUnaryOperatorsInMethodCall:ERROR
     -Xep:NumericEquality:ERROR
     -Xep:ObjectToString:ERROR
     -Xep:OptionalNotPresent:ERROR
     -Xep:ShortCircuitBoolean:ERROR
     -Xep:StaticGuardedByInstance:ERROR
     -Xep:StaticQualifiedUsingExpression:ERROR
     -Xep:StringEquality:ERROR
     -Xep:SynchronizeOnNonFinalField:ERROR
     -Xep:VarTypeName:ERROR
</arg>

@ctabin
Copy link
Author

ctabin commented Oct 8, 2018

Hello @tbroyer,

Thanks for your replay, it works. I didn't find any example of this in the documentation. And as I read this, @don-vip says that the version 2.3.1 should work with JDK 11.

Anyway, now that I'm falling on the same error as #1083, we're waiting for release 2.3.2 👍

Best regards,
Cédric

@ctabin ctabin closed this as completed Oct 8, 2018
@tbroyer
Copy link
Contributor

tbroyer commented Oct 8, 2018

#1115 😉

cpovirk added a commit to google/jimfs that referenced this issue Oct 4, 2019
- We may want an ICU4J new enough to contain an Automatic-Module-Name.
- Our old maven-surefire-plugin breaks with NullPointerException with JDK10+: https://bugzilla.redhat.com/show_bug.cgi?id=1572708
- Our old maven-compiler-plugin breaks with JDK11: google/error-prone#1136 (comment) (I don't have the error message handy anymore.)

RELNOTES=n/a

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=272714574
cpovirk added a commit to google/jimfs that referenced this issue Oct 4, 2019
- We may want an ICU4J new enough to contain an Automatic-Module-Name.
- Our old maven-surefire-plugin breaks with NullPointerException with JDK10+: https://bugzilla.redhat.com/show_bug.cgi?id=1572708
- Our old maven-compiler-plugin breaks with JDK11: google/error-prone#1136 (comment) (I don't have the error message handy anymore.)

RELNOTES=n/a

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=272714574
cpovirk added a commit to google/jimfs that referenced this issue Oct 4, 2019
If run in the old style, it uses javac9, which can't handle the Java 11 class files in the JDK11 bootclasspath.

This follows the instructions at https://errorprone.info/docs/installation#maven

Note also the need to include -Xep:BetaApi:OFF in the same arg as -Xplugin:ErrorProne: google/error-prone#1136 (comment) google/error-prone#1115

(Also, incidentally update Error Prone itself. I forget whether I had a Java-11-related reason for that, but it seems like a good idea.)

RELNOTES=n/a

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=272934125
cpovirk added a commit to google/jimfs that referenced this issue Oct 4, 2019
If run in the old style, it uses javac9, which can't handle the Java 11 class files in the JDK11 bootclasspath.

This follows the instructions at https://errorprone.info/docs/installation#maven

Note also the need to include -Xep:BetaApi:OFF in the same arg as -Xplugin:ErrorProne: google/error-prone#1136 (comment) google/error-prone#1115

(Also, incidentally update Error Prone itself. I forget whether I had a Java-11-related reason for that, but it seems like a good idea.)

RELNOTES=n/a

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=272934125
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

No branches or pull requests

2 participants