Java 9 (build 9-ea+170) issues

Hi

I tried to start Gradle 3.5 on the latest JDK 9 build (170) using advises from similar topics here:

export GRADLE_OPTS=–add-opens java.base/java.lang=ALL-UNNAMED

However when I start my build I get the following exception. Can you please help?

    at org.gradle.launcher.daemon.bootstrap.DaemonGreeter.parseDaemonOutput(DaemonGreeter.java:34)
    at org.gradle.launcher.daemon.client.DefaultDaemonStarter.startProcess(DefaultDaemonStarter.java:152)
    at org.gradle.launcher.daemon.client.DefaultDaemonStarter.startDaemon(DefaultDaemonStarter.java:135)
    at org.gradle.launcher.daemon.client.DefaultDaemonConnector.startDaemon(DefaultDaemonConnector.java:208)
    at org.gradle.launcher.daemon.client.DefaultDaemonConnector.connect(DefaultDaemonConnector.java:130)
    at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:127)
    at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:81)
    at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:51)
    at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:173)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:281)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:254)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:33)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:247)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:182)
    at org.gradle.launcher.Main.doAction(Main.java:33)
    at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
    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:563)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:60)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)
    at org.gradle.launcher.GradleMain.main(GradleMain.java:23)

Thanks

@Strannik, are you sure that’s the whole stack trace?

I don’t expect Gradle 3.8 to run on the latest JDK 9 (build 170.) But, I do expect a different stack trace.

For more information on the work we are doing to get Gradle running correctly with the latest early-availability releases of the JDK, please follow along on:

Hi @eljobe

Yes, that’s the full stack trace. I tested it today.

Thanks for the update. I can confirm that with Gradle 3.5, the exception is different than the one produced by one of the nightly builds from our 4.0 snapshot. Thanks for the report.

Instead of setting GRADLE_OPTS, try setting JDK_JAVA_OPTIONS.
You will need different opens depending on what you gradle files use.
If you want to open everything up just to see if it works, export JDK_JAVA_OPTIONS=
"–permit-illegal-access -Djdk.attach.allowAttachSelf=true"

Hi @eljobe @sdfelts

Thank you for the suggestions. I could resolve all the issues with starting Gradle using JDK_JAVA_OPTIONS environment variable(using --permit-illegagl-access or --add-opens flags).

However I have another issue with compiling my code:

error: package javax.annotation is not visible
(package javax.annotation is declared in module java.xml.ws.annotation, which is not in the module graph)

I tried to specify compiler options for the build:

compileJava {
options.compilerArgs += ["–add-modules java.xml.ws.annotation"]
}

However I got compiler error after that stating that --add-modules flag is invalid.

Any help, please?

Important update.

The last issue happened only if I set sourceCompatibility/targetCompatibility to 1.9.

The syntax is wrong. You need to add the values as two separate values.
options.compilerArgs +=[ “–add-modules”]
options.compilerArgs += [“java.xml.ws.annotation”]

2 Likes