guice compatibility with Java 9: "WARNING: Illegal reflective access by com.google.inject.internal."

Bug #1754602 reported by fcole90
48
This bug affects 10 people
Affects Status Importance Assigned to Milestone
Guice
Fix Released
Unknown
guice (Ubuntu)
Confirmed
Undecided
Unassigned
maven (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

The `guice` version provided by maven seem not to be compatible with Java 9 as it throws the following warnings:

```
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
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
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
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
```

The related issue was already reported and resolved in upstream guice: https://github.com/google/guice/issues/1085

ProblemType: Bug
DistroRelease: Ubuntu 18.04
Package: maven 3.5.2-2
ProcVersionSignature: Ubuntu 4.15.0-11.12-generic 4.15.5
Uname: Linux 4.15.0-11-generic x86_64
ApportVersion: 2.20.8-0ubuntu10
Architecture: amd64
CurrentDesktop: ubuntu:GNOME
Date: Fri Mar 9 11:28:26 2018
InstallationDate: Installed on 2017-08-21 (199 days ago)
InstallationMedia: Ubuntu 17.10 "Artful Aardvark" - Alpha amd64 (20170820)
PackageArchitecture: all
SourcePackage: maven
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
fcole90 (fcole90) wrote :
summary: - guice version not compatible with Java 9
+ guice compatibility with Java 9: "WARNING: Illegal reflective access by
+ com.google.inject.internal."
Changed in guice:
status: Unknown → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in guice (Ubuntu):
status: New → Confirmed
Changed in maven (Ubuntu):
status: New → Confirmed
Revision history for this message
Aldric (picpic) wrote :

Hello!

Same with jdk11 and maven 3.6.3.

➜ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04 LTS
Release: 20.04
Codename: focal

➜ mvn --version
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 11.0.7, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_GB, platform encoding: UTF-8
OS name: "linux", version: "5.4.0-33-generic", arch: "amd64", family: "unix"

➜ mvn clean
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
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
[INFO] Scanning for projects...
[INFO]

Regards

Revision history for this message
Bernt (bernt-hullen) wrote :

Hallo,

It's the same error with Ubuntu 20.10

mvn --version
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 11.0.10, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.8.0-44-generic", arch: "amd64", family: "unix"

Revision history for this message
mjw99 (mark-williamson) wrote :

Now seeing this manifest as an ERROR in JDK16 and Ubuntu 20.10:

$ java -version
openjdk version "16" 2021-03-16
OpenJDK Runtime Environment (build 16+36-2231)
OpenJDK 64-Bit Server VM (build 16+36-2231, mixed mode, sharing)

$ mvn clean test
[ERROR] Error executing Maven.
[ERROR] java.lang.IllegalStateException: Unable to load cache item
[ERROR] Caused by: Unable to load cache item
[ERROR] Caused by: Could not initialize class com.google.inject.internal.cglib.core.$MethodWrapper

This essentially breaks any CI that uses a 20.10 image with JDK16.

It might be worth looking at how the Debian people fixed this:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=980467

Revision history for this message
Alexander Levsha (endeavourl) wrote :

Is there any activity on this bug? Currently maven from this package is unusable when using latest Java 16.

Revision history for this message
John Neffenger (jgneff) wrote :

See also the following bug reported by Manuel J. on 2021-06-02:

Maven 3.6.3-1 fails to run with OpenJDK 16
https://bugs.launchpad.net/ubuntu/+source/maven/+bug/1930541

Perhaps this bug report should be marked as a duplicate of Bug #1930541 above, as the illegal reflective access is now an error with OpenJDK 16 instead of the prior warnings.

Revision history for this message
Masanori Itoh (thatsdone) wrote :

Hi, this issue looks like resolved at least the following conditions.

* Ubuntu 21.04 (nightly build at 20210917
* openjdk-16-jre-headless:amd64 16.0.1+9-1
* maven 3.6.3-5
* libguice-java 4.2.3-2

```
mitoh@mitoh-u2104a:~/test1$ mvn -version
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 16.0.1, vendor: Private Build, runtime: /usr/lib/jvm/java-16-openjdk-amd64
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "5.11.0-34-generic", arch: "amd64", family: "unix"
mitoh@mitoh-u2104a:~/test1$ ls
pom.xml src
mitoh@mitoh-u2104a:~/test1$ mvn clean
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< com.example:test1 >--------------------------
[INFO] Building test1 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ test1 ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.150 s
[INFO] Finished at: 2021-09-26T01:02:39Z
[INFO] ------------------------------------------------------------------------
mitoh@mitoh-u2104a:~/test1$
```

For me, current problem is how to backport them to 20.04 LTS.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.