Gradle on OpenJDK 8: java.lang.NoSuchMethodError: java.lang.invoke.MethodHandles.privateLookupIn()
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
gradle (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Bionic |
Fix Released
|
Undecided
|
Unassigned | ||
Cosmic |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
[Impact]
gradle cannot be run with openjdk-8 after the update to 4.4.1-5~18.04 (bionic-proposed) or 4.4.1-5~18.10 (cosmic-proposed).
When running it with openjdk-8 gradle fails with
$ gradle -g /tmp --debug --stacktrace --foreground
<snip>
Caused by: java.lang.
java.lang.
<snip>
This is caused by the java11-
With the upstream fix applied another issue related to the ByteBuffer shows up and can be fixed by updating the java8-compatibility patch to include a cast in org.gradle.
[Test Case]
All tests assume that bionic-proposed and cosmic-proposed are enabled.
NOTE: It is important to clear gradle files between runs as it can cache some data that will prevent or hide some issues.
$ rm -rf /tmp/native /tmp/daemon /tmp/caches/
the directories above are due to the usage of the "-g /tmp" flag.
Install gradle, openjdk-8, and openjdk-11.
$ apt install gradle openjdk-8-jdk openjdk-11-jdk default-jdk
By default gradle will use the default java (ie. java-11), check this:
$ gradle -version
<snip>
Groovy: 2.4.16
Ant: Apache Ant(TM) version 1.10.5 compiled on March 5 2019
JVM: 11.0.2 (Oracle Corporation 11.0.2+
OS: Linux 4.19.0-13-generic amd64
Now run gradle with openjdk-11
$ gradle -g /tmp --debug --stacktrace --foreground
Use openjdk-8 by default
$ sudo update-
Check gradle version again
$ gradle -version
<snip>
Groovy: 2.4.16
Ant: Apache Ant(TM) version 1.10.5 compiled on March 5 2019
JVM: 1.8.0_191 (Oracle Corporation 25.191-b12)
OS: Linux 4.19.0-13-generic amd64
Clear gradle files
$ rm -rf /tmp/native /tmp/daemon /tmp/caches/
$ gradle -g /tmp --debug --stacktrace --foreground
<snip>
Caused by: java.lang.
java.lang.
<snip>
With the above fixed the following error is show and required a patch for java8-compatibility
$ gradle -g /tmp --debug --stacktrace
<snip>
01:53:01.821 [ERROR] [org.gradle.
01:53:01.822 [ERROR] [org.gradle.
<snip>
[Regression Potential]
The upstream fix actually enables openjdk-8 to be used again with gradle, no other regressions are expected due to that patch.
The ByteBuffer to Buffer cast is also a known fix for openjdk-8 compatibility and no regressions is expected.
[Other Info]
References:
[1] https:/
[Original bug report]
Just tried the proposed Gradle package on Ubuntu 18.04 LTS. As I cannot yet use OpenJDK 11, I switched all Java alternatives back to OpenJDK 8 using
sudo update-
Now, when I try to build my project I get the above generic error. Full console output:
$ gradle --no-daemon clean installDebug
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https:/
FAILURE: Build failed with an exception.
* What went wrong:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at https:/
Please read the following process output to find out more:
-------
FAILURE: Build failed with an exception.
* What went wrong:
java.lang.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https:/
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https:/
ProblemType: Bug
DistroRelease: Ubuntu 18.04
Package: gradle 4.4.1-5~18.04
ProcVersionSign
Uname: Linux 4.18.0-16-generic x86_64
ApportVersion: 2.20.9-0ubuntu7.5
Architecture: amd64
CurrentDesktop: ubuntu:GNOME
Date: Sat Mar 16 11:56:15 2019
EcryptfsInUse: Yes
InstallationDate: Installed on 2016-04-21 (1058 days ago)
InstallationMedia: Ubuntu 16.04 LTS "Xenial Xerus" - Release amd64 (20160420.1)
PackageArchitec
SourcePackage: gradle
UpgradeStatus: Upgraded to bionic on 2018-04-26 (323 days ago)
tags: | added: bot-stop-nagging |
tags: | added: regression-proposed |
description: | updated |
description: | updated |
The full exception is.
java.lang. ExceptionInInit ializerError internal. classloader. FilteringClassL oader.< clinit> (FilteringClass Loader. java:48) initialization. DefaultClassLoa derRegistry. restrictTo( DefaultClassLoa derRegistry. java:40) initialization. DefaultClassLoa derRegistry. restrictToGradl eApi(DefaultCla ssLoaderRegistr y.java: 36) initialization. DefaultClassLoa derRegistry. <init>( DefaultClassLoa derRegistry. java:30) internal. service. scopes. GlobalScopeServ ices.createClas sLoaderRegistry (GlobalScopeSer vices.java: 207) NativeMethodAcc essorImpl. invoke0( Native Method) NativeMethodAcc essorImpl. invoke( NativeMethodAcc essorImpl. java:62) DelegatingMetho dAccessorImpl. invoke( DelegatingMetho dAccessorImpl. java:43) reflect. Method. invoke( Method. java:498) internal. reflect. JavaMethod. invoke( JavaMethod. java:73) internal. service. ReflectionBased ServiceMethod. invoke( ReflectionBased ServiceMethod. java:35) internal. service. DefaultServiceR egistry$ FactoryMethodSe rvice.invokeMet hod(DefaultServ iceRegistry. java:795) internal. service. DefaultServiceR egistry$ FactoryService. create( DefaultServiceR egistry. java:748) internal. service. DefaultServiceR egistry$ ManagedObjectPr ovider. getInstance( DefaultServiceR egistry. java:574) internal. service. DefaultServiceR egistry$ SingletonServic e.get(DefaultSe rviceRegistry. java:623) internal. service. DefaultServiceR egistry. applyConfigureM ethod(DefaultSe rviceRegistry. java:199) internal. service. DefaultServiceR egistry. findProviderMet hods(DefaultSer viceRegistry. java:180) internal. service. DefaultServiceR egistry. addProvider( DefaultServiceR egistry. java:255) internal. service. ServiceRegistry Builder. build(ServiceRe gistryBuilder. java:52) launcher. cli.BuildAction sFactory. runBuildInProce ss(BuildActions Factory. java:129) launcher. cli.BuildAction sFactory. createAction( BuildActionsFac tory.java: 90) launcher. cli.CommandLine ActionFactory$ ParseAndBuildAc tion.createActi on(CommandLineA ctionFactory. java:296) launcher. cli.CommandLine ActionFactory$ ParseAndBuildAc tion.execute( CommandLineActi onFactory. java:286) launcher. cli.CommandLine ActionFactory$ ParseAndBuildAc tion.execute( CommandLineActi onFactory. java:264) launcher. cli.JavaRuntime ValidationActio n.execute( JavaRuntimeVali dationAction. java:33) launcher. cli.JavaRuntime ValidationActio n.execute( JavaRuntimeVali dationAction. java:24) launcher. cli.ExceptionRe portingAction. execute( ExceptionReport ingAction. java:33) launcher. cli.ExceptionRe portingAction. execute( ExceptionReport ingAction. java:22) launcher. cli.CommandLine ActionFactory$ WithLogging. execute( CommandLineActi onFactory. java:257) launcher. ..
at org.gradle.
at org.gradle.
at org.gradle.
at org.gradle.
at org.gradle.
at sun.reflect.
at sun.reflect.
at sun.reflect.
at java.lang.
at org.gradle.
at org.gradle.
at org.gradle.
at org.gradle.
at org.gradle.
at org.gradle.
at org.gradle.
at org.gradle.
at org.gradle.
at org.gradle.
at org.gradle.
at org.gradle.
at org.gradle.
at org.gradle.
at org.gradle.
at org.gradle.
at org.gradle.
at org.gradle.
at org.gradle.
at org.gradle.
at org.gradle.