Fixed
Status Update
Comments
da...@gmail.com <da...@gmail.com> #2
The root cause is in ./java/com/google/gerrit/common/IoUtil.java:
Method addURL;
try {
addURL = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
addURL.setAccessible(true);
} catch (SecurityException | NoSuchMethodException e) {
throw noAddURL("Method addURL not available", e);
}
Method addURL;
try {
addURL = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
addURL.setAccessible(true);
} catch (SecurityException | NoSuchMethodException e) {
throw noAddURL("Method addURL not available", e);
}
da...@gmail.com <da...@gmail.com> #3
[Empty comment from Monorail migration]
da...@gmail.com <da...@gmail.com> #4
[Empty comment from Monorail migration]
da...@gmail.com <da...@gmail.com> #6
[Empty comment from Monorail migration]
gi...@appspot.gserviceaccount.com <gi...@appspot.gserviceaccount.com> #7
The following revision refers to this bug:
https://gerrit.googlesource.com/gerrit/+/9970f17601ed4efe6a2f5f844a3a93684822fb78
commit 9970f17601ed4efe6a2f5f844a3a93684822fb78
Author: David Ostrovsky <david@ostrovsky.org>
Date: Mon May 22 07:54:18 2023
Use custom gerrit class loader to avoid usage of reflection
Starting from Java 17, JEP 403: Strongly Encapsulate JDK Internals: [1]
it's not possible to access internal methods per reflection.
Particularly, it's not possible to call protected method per relfection:
URLClassLoader#addURL(). To rectify, define custom class loader class
and declare addURL() als method with public access modifier.
[1]https://openjdk.org/jeps/403
Release-Notes: skip
Bug:https://crbug.com/gerrit/15994
Change-Id: I568a5d91a3ffedb165de3ee3fbc495a5ae7a9cbe
[modify]https://gerrit.googlesource.com/gerrit/+/9970f17601ed4efe6a2f5f844a3a93684822fb78/java/com/google/gerrit/common/BUILD
[modify]https://gerrit.googlesource.com/gerrit/+/9970f17601ed4efe6a2f5f844a3a93684822fb78/java/com/google/gerrit/launcher/GerritLauncher.java
[modify]https://gerrit.googlesource.com/gerrit/+/9970f17601ed4efe6a2f5f844a3a93684822fb78/java/com/google/gerrit/common/IoUtil.java
commit 9970f17601ed4efe6a2f5f844a3a93684822fb78
Author: David Ostrovsky <david@ostrovsky.org>
Date: Mon May 22 07:54:18 2023
Use custom gerrit class loader to avoid usage of reflection
Starting from Java 17, JEP 403: Strongly Encapsulate JDK Internals: [1]
it's not possible to access internal methods per reflection.
Particularly, it's not possible to call protected method per relfection:
URLClassLoader#addURL(). To rectify, define custom class loader class
and declare addURL() als method with public access modifier.
[1]
Release-Notes: skip
Bug:
Change-Id: I568a5d91a3ffedb165de3ee3fbc495a5ae7a9cbe
[modify]
[modify]
[modify]
da...@gmail.com <da...@gmail.com> #8
[Empty comment from Monorail migration]
Description
What steps will reproduce the problem?
1. Switch to using Java 17
2. Put some library in <gerrit_site>/lib directory, for example MariaDB connector
3. Start init program
What is the expected output?
init program works as expected
What do you see instead?
init program crashes with this error:
fatal: Learn more:https://github.com/google/guice/wiki/ERROR_IN_CUSTOM_PROVIDER
fatal:
fatal: Caused by: InaccessibleObjectException: Unable to make protected void URLClassLoader.addURL(URL) accessible: module java.base does not "opens java.net" to unnamed module @35d019a3
fatal: at java.base/AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
fatal: at java.base/AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
fatal: at java.base/Method.checkCanSetAccessible(Method.java:199)
fatal: at java.base/Method.setAccessible(Method.java:193)
fatal: at IoUtil.loadJARs(IoUtil.java:83)
fatal: at SiteLibraryLoaderUtil.loadSiteLib(SiteLibraryLoaderUtil.java:38)
[...]
fatal:
fatal: Unable to make protected void java.net.URLClassLoader.addURL(java.net.URL) accessible: module java.base does not "opens java.net" to unnamed module @35d019a3
Please provide any additional information below.
The problem is Strongly Encapsulate JDK Internals: [1].
A similar problem was solved in context of this issue: [2],
in this PR: [3].
Workaround for now is to put this line in <gerrit_site>/etc/gerrit.config:
javaOptions = "--add-opens java.base/java.net=ALL-UNNAMED"
and run init program with
java --add-opens java.base/java.net=ALL-UNNAMED -jar gerrit.war init -d <gerrit_site>
[1]https://openjdk.java.net/jeps/403 https://github.com/LuckPerms/LuckPerms/issues/2853 https://github.com/LuckPerms/LuckPerms/pull/2899
[2]
[3]