Skip to content

Commit

Permalink
Reset findLoadedClassMethod in case of makeAccessible failing
Browse files Browse the repository at this point in the history
Closes gh-31232
  • Loading branch information
jhoeller committed Sep 14, 2023
1 parent 062c624 commit 54c4f1b
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,15 @@ class ContextTypeMatchClassLoader extends DecoratingClassLoader implements Smart
// override classes that have not been loaded yet. If not accessible, we will
// always override requested classes, even when the classes have been loaded
// by the parent ClassLoader already and cannot be transformed anymore anyway.
Method method = null;
Method method;
try {
method = ClassLoader.class.getDeclaredMethod("findLoadedClass", String.class);
ReflectionUtils.makeAccessible(method);
}
catch (Throwable ex) {
// Typically a JDK 9+ InaccessibleObjectException...
// Avoid through JVM startup with --add-opens=java.base/java.lang=ALL-UNNAMED
method = null;
LogFactory.getLog(ContextTypeMatchClassLoader.class).debug(
"ClassLoader.findLoadedClass not accessible -> will always override requested class", ex);
}
Expand Down

0 comments on commit 54c4f1b

Please sign in to comment.