gradle: "illegal reflective access" with openjdk-9

Bug #1760359 reported by Andreas Schildbach on 2018-03-31
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gradle (Ubuntu)
Tiago Stürmer Daitx

Bug Description

Since a couple of days, gradle doesn't work on Ubuntu 18.04 LTS any more on openjdk8. Installing openjdk9 kind of works around this problem, but it throws a couple of scary illegal access warnings instead. Just a days ago, everything worked fine so there must have been some bug introduced into a dependent package.

$ gradle -S
Starting a Gradle Daemon, 8 busy and 2 incompatible and 1 stopped Daemons could not be reused, use --status for details

FAILURE: Build failed with an exception.

* What went wrong:

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
java.lang.NoSuchMethodError: java.nio.ByteBuffer.limit(I)Ljava/nio/ByteBuffer;
        at org.gradle.internal.remote.internal.inet.SocketConnection$SocketInputStream.<init>(
        at org.gradle.internal.remote.internal.inet.SocketConnection.<init>(
        at org.gradle.internal.remote.internal.inet.SocketConnectCompletion.create(
        at org.gradle.launcher.daemon.client.DefaultDaemonConnector.connectToDaemon(
        at org.gradle.launcher.daemon.client.DefaultDaemonConnector.connectToDaemonWithId(
        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 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(
        at java.lang.reflect.Method.invoke(
        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(
        at org.gradle.launcher.GradleMain.main(

ProblemType: Bug
DistroRelease: Ubuntu 18.04
Package: gradle 3.4.1-4
ProcVersionSignature: Ubuntu 4.15.0-13.14-generic 4.15.10
Uname: Linux 4.15.0-13-generic x86_64
ApportVersion: 2.20.9-0ubuntu2
Architecture: amd64
CurrentDesktop: ubuntu:GNOME
Date: Sun Apr 1 00:04:40 2018
InstallationDate: Installed on 2013-01-11 (1905 days ago)
InstallationMedia: Ubuntu 12.10 "Quantal Quetzal" - Release amd64 (20121017.5)
PackageArchitecture: all
 PATH=(custom, no user)
SourcePackage: gradle
UpgradeStatus: Upgraded to bionic on 2018-03-07 (24 days ago)

Andreas Schildbach (schildbach) wrote :
Andreas Schildbach (schildbach) wrote :

I think the issue that Gradle has been updated to the Debian experimental version 3.4.1. Before, it was synched to "unstable" 3.2.1.

Steve Langasek (vorlon) wrote :

openjdk-8 will not be supported in 18.04, as discussed in <>, <>. The java-common package points to openjdk-9 today, and while openjdk-8 will be retained in universe for 18.04 for compatibility, there is no committment that any other particular package will remain compatible with openjdk-8.

What are the "scary illegal access warnings" that you see with openjdk-9?

Changed in gradle (Ubuntu):
status: New → Incomplete
Andreas Schildbach (schildbach) wrote :

Thanks Steve for the clarification. I personally feel the (forced) move to Java9 comes too early, as I
just have moved my Android projects to Java8 with quite some headache. But I guess I have to adapt.

Here is the output of gradle under openjdk-9. The first 5 lines are always the same regardless of the parameters.

$ gradle
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.gradle.internal.reflect.JavaMethod (file:/usr/share/gradle/lib/gradle-base-services-3.4.1.jar) to method java.lang.ClassLoader.getPackages()
WARNING: Please consider reporting this to the maintainers of org.gradle.internal.reflect.JavaMethod
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

Welcome to Gradle 3.4.1.

To run a build, run gradle <task> ...

To see a list of available tasks, run gradle tasks

To see a list of command-line options, run gradle --help

To see more detail about a task, run gradle help --task <task>


Total time: 1.105 secs

Steve Langasek (vorlon) wrote :

Thanks. That definitely looks like something we should be fixing for 18.04.

summary: - Regression: java.lang.NoSuchMethodError:
- java.nio.ByteBuffer.limit(I)Ljava/nio/ByteBuffer;
+ gradle: "illegal reflective access" with openjdk-9
Changed in gradle (Ubuntu):
assignee: nobody → Tiago Stürmer Daitx (tdaitx)
status: Incomplete → Triaged
importance: Undecided → Medium
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gradle - 3.4.1-6

gradle (3.4.1-6) unstable; urgency=medium

  * Team upload.
  * Improved the Java 8 compatibility patch

 -- Emmanuel Bourg <email address hidden> Thu, 05 Apr 2018 08:39:52 +0200

Changed in gradle (Ubuntu):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers