Error-prone: JDK 9 support

Created on 17 Aug 2016  路  12Comments  路  Source: google/error-prone

When I try to compile my project using JDK 9 (https://jdk9.java.net/download/), I get following error.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project artemis-commons: Fatal error compiling: CompilerException: InvocationTargetException: java.nio.file.NotDirectoryException: /opt/jdk1.9.ea/lib/modules -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project artemis-commons: Fatal error compiling
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    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:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base@9-ea/Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base@9-ea/NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@9-ea/DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(java.base@9-ea/Method.java:535)
    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)
Caused by: org.apache.maven.plugin.MojoExecutionException: Fatal error compiling
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:796)
    at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    ... 20 more
Caused by: org.codehaus.plexus.compiler.CompilerException
    at org.codehaus.plexus.compiler.javac.errorprone.JavacCompilerWithErrorProne.performCompile(JavacCompilerWithErrorProne.java:95)
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:785)
    ... 23 more
Caused by: java.lang.reflect.InvocationTargetException
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base@9-ea/Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base@9-ea/NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@9-ea/DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(java.base@9-ea/Method.java:535)
    at org.codehaus.plexus.compiler.javac.errorprone.JavacCompilerWithErrorProne.performCompile(JavacCompilerWithErrorProne.java:91)
    ... 24 more
Caused by: java.io.UncheckedIOException: java.nio.file.NotDirectoryException: /opt/jdk1.9.ea/lib/modules
    at com.sun.tools.javac.file.Locations$BootClassPathLocationHandler.lazy(Locations.java:725)
    at com.sun.tools.javac.file.Locations$BootClassPathLocationHandler.isDefault(Locations.java:559)
    at com.sun.tools.javac.file.Locations.isDefaultBootClassPath(Locations.java:129)
    at com.sun.tools.javac.file.BaseFileManager.isDefaultBootClassPath(BaseFileManager.java:149)
    at com.sun.tools.javac.main.Arguments.validate(Arguments.java:411)
    at com.sun.tools.javac.main.Main.compile(Main.java:218)
    at com.google.errorprone.BaseErrorProneCompiler.run(BaseErrorProneCompiler.java:190)
    at com.google.errorprone.BaseErrorProneCompiler.run(BaseErrorProneCompiler.java:101)
    at com.google.errorprone.ErrorProneCompiler.run(ErrorProneCompiler.java:131)
    at com.google.errorprone.ErrorProneCompiler.compile(ErrorProneCompiler.java:73)
    at org.codehaus.plexus.compiler.javac.errorprone.JavacCompilerWithErrorProne$CompilerInvoker.compile(JavacCompilerWithErrorProne.java:219)
    ... 29 more
Caused by: java.nio.file.NotDirectoryException: /opt/jdk1.9.ea/lib/modules
    at sun.nio.fs.UnixFileSystemProvider.newDirectoryStream(java.base@9-ea/UnixFileSystemProvider.java:427)
    at java.nio.file.Files.newDirectoryStream(java.base@9-ea/Files.java:460)
    at java.nio.file.Files.list(java.base@9-ea/Files.java:3506)
    at com.sun.tools.javac.file.Locations$BootClassPathLocationHandler.systemClasses(Locations.java:678)
    at com.sun.tools.javac.file.Locations$BootClassPathLocationHandler.computePath(Locations.java:634)
    at com.sun.tools.javac.file.Locations$BootClassPathLocationHandler.lazy(Locations.java:722)
    ... 39 more

The error-prone-javac assumes that $JAVA_HOME/lib/modules is a directory but in my case it is regular file. I use 1.9.0-dev-r2973-2 version of error-prone-javac.

Most helpful comment

Error Prone should run on JDK 9 now (see the "Java 9" section http://errorprone.info/docs/installation for instructions). If anyone encounters issues using it from the command line that way, please let us know.

We haven't done as much testing of the build system integrations: Bazel will work soon, there's an issue open for gradle (tbroyer/gradle-errorprone-plugin/issues/27), and I'm not sure about maven yet.

Support for using the Java 9 language level (not just running the tool on JDK 9) is work in progress.

All 12 comments

We're not yet supporting running on JDK 9.

The current version of error-prone-javac was cut before Project Jigsaw (i.e. the module system) landed. It will require significant work for us to run on a modularized JDK. We are working on this internally, but it's low priority as the JDK 9 release date is more than 6 months away.

I see. Thank you for your response.

WIth Java 9 coming later this year, I thought it'd be good to start occasionally tracking it with our builds, but hit this problem - any word on when some support might be available in error_prone?

We still don't have a firm timeline for this. @cushon might have thoughts.

It's a bit weird to me you guys closing this issue without being fixed.. no plans to fix it?

we are using it on activemq artemis.. we may have to remove error prone otherwise we won't be able to move to jdk1.9.

Is this still happening with recent JDK 9 EA builds and Error Prone 2.0.20-SNAPSHOT?

I didn't try with a snapshot of Error Prone.. I can try it later today:

We were having a discussion here:

http://activemq.2283324.n4.nabble.com/DISCUSS-Artemis-JDK9-support-tp4725823.html;cid=1494353758727-471

if you want to be part of the discussion, you can subscribe to the dev list:

http://activemq.apache.org/mailing-lists.html

if you want to build it and try yourself:

https://github.com/apache/activemq-artemis/

a simple git clone and mvn install would do!

Let's leave this bug open to track JDK 9 support. I'm not sure we can commit to supporting JDK 9 before it's released, but it's definitely something we plan to do eventually.

@clebertsuconic I can build activemq-artemis with JDK 9-ea+168 and Error Prone 2.0.20-SNAPSHOT. I started with the fixes in ARTEMIS-683 and then re-enabled Error Prone.

  • -Xep:StaticAccessedFromInstance:ERROR needs to be updated to -Xep:StaticQualifiedUsingExpression:ERROR
  • I made a small change to Error Prone to work around JDK-8152842 that I'll submit soon
  • Error Prone reported a handful of new errors in the code that will need to be fixed or suppressed

Error Prone should run on JDK 9 now (see the "Java 9" section http://errorprone.info/docs/installation for instructions). If anyone encounters issues using it from the command line that way, please let us know.

We haven't done as much testing of the build system integrations: Bazel will work soon, there's an issue open for gradle (tbroyer/gradle-errorprone-plugin/issues/27), and I'm not sure about maven yet.

Support for using the Java 9 language level (not just running the tool on JDK 9) is work in progress.

@cushon Can you please post the issue ID for the Java 9 language features? So one could track progress of that. :-)

The ant integration is broken for JDK 9 because (at least) of this line:
https://github.com/google/error-prone/blob/master/ant/src/main/java/com/google/errorprone/ErrorProneExternalCompilerAdapter.java#L93

-XbootClasspath/p isn't supported in Java 9, and the error-prone installation instructions recommend a different integration method for Java 9.

We need up update the rest of the build system installation docs to mention the -Xplugin integration, but Java 9, 10, and 11 are supported now: #860

Was this page helpful?
0 / 5 - 0 ratings