Skip to content

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

Closed
@ctabin

Description

@ctabin

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 !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions