tbroyer/gradle-errorprone-plugin-v0.0.x

JDK9 support

ben-manes opened this issue · 11 comments

Using 9ea and Gradle 3.0, the plugin has to be disabled due to the error

Caused by: java.lang.NoClassDefFoundError: Could not initialize class net.ltgt.gradle.errorprone.ErrorProneCompiler$SelfFirstClassLoader
        at net.ltgt.gradle.errorprone.ErrorProneCompiler.execute(ErrorProneCompiler.java:51)
        at net.ltgt.gradle.errorprone.ErrorProneCompiler.execute(ErrorProneCompiler.java:25)

Reproduced.

Looks like the Jvm.current().getToolsJar().… throws an NPE (expected, as there's no tools.jar in JDK 9 any longer), but removing it (using a URLClassLoader with no entries) then fails with an NPE during the compilation, because that System.getProperty("sun.boot.class.path") returns null (see http://openjdk.java.net/jeps/261).

I think Error Prone simply is not compatible with JDK 9 yet.

See google/error-prone#448 (comment)

We're not yet supporting running on JDK 9.

So, I'll change the plugin to support JDK 9 (i.e. no longer fail when there's no tools.jar), but you'll have to wait for Error Prone to support JDK 9 to be able to actually use it.

In retrospect, not really knowing how Error Prone will tackle the problem, it's probably safer to wait for them to support JDK 9 and only then update the plugin accordingly. WDYT?

I'm fine disabling in my build. I think being explicit is reasonable.

FWIW, 8aa08a8 (shipped in 0.0.9) now handles the case where Jvm.current().getToolsJar() returns null; so with JDK 9 the build should now fail with an explicit error message hinting that the JDK might not be compatible (I can't even make Gradle start with Java 9 though…).

(leaving this issue open as this will need to change anyway once Error Prone supports JDK 9)

It looks like JDK 9 support is becoming official through the use of the -Xplugin flag: google/error-prone#681

I'd rather wait for the final JDK 9 release before making any change though (if any, having to use the -processorpath could easily conflict with other plugins or JavaCompile tasks' configuration, so maybe this plugin will actually never support JDK 9, by design).

Finally released so a bunch of tooling is officially busted. ;)

A PR hits the "no tools.jar" wall junit-team/junit5#961 -- any news on supporting JDK 9?

Let me have a look at it. It looks like tools.jar is actually not (no longer?) needed with Java 8 (actually, that was probably a requirement of ErrorProne 1.x, remove from 2.x when it started using its own javac; and I recently removed support for Java 7 and ErrorProne 1.x), and ErrorProne would then work in a JDK 9 environment.
Needs more testing…

I just release v0.0.13 which works with Java 9; but please note that Error Prone does not support JPMS or the --release flag (to guarantee backwards-compatibility with JDK 7 or JDK 8, without the need to use those JDKs when compiling), among other things.

Closing this issue, as things are now on Error Prone's side.

I just release v0.0.13 which works with Java 9

Thanks Thomas!

please note that Error Prone does not support JPMS or the --release flag (to guarantee backwards-compatibility with JDK 7 or JDK 8, without the need to use those JDKs when compiling), among other things.

Okay for me. :)