Java 9 (build 9-ea+170) issues


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(
    at org.gradle.launcher.daemon.client.DefaultDaemonStarter.startProcess(
    at org.gradle.launcher.daemon.client.DefaultDaemonStarter.startDaemon(
    at org.gradle.launcher.daemon.client.DefaultDaemonConnector.startDaemon(
    at org.gradle.launcher.daemon.client.DefaultDaemonConnector.connect(
    at org.gradle.launcher.daemon.client.DaemonClient.execute(
    at org.gradle.launcher.daemon.client.DaemonClient.execute(
    at org.gradle.internal.Actions$RunnableActionAdapter.execute(
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(
    at org.gradle.launcher.Main.doAction(
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.base/java.lang.reflect.Method.invoke(
    at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(
    at org.gradle.launcher.GradleMain.main(


@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, which is not in the module graph)

I tried to specify compiler options for the build:

compileJava {
options.compilerArgs += ["–add-modules"]

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 += [“”]