Improve diagnostics for CGLIB ClassLoader mismatch with --add-opens hint
Closes gh-28747
This commit is contained in:
parent
d72aeac319
commit
de1b938e2e
|
|
@ -490,7 +490,7 @@ public class ReflectUtils {
|
|||
return defineClass(className, b, loader, protectionDomain, null);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation") // on JDK 9
|
||||
@SuppressWarnings({"deprecation", "serial"})
|
||||
public static Class defineClass(String className, byte[] b, ClassLoader loader,
|
||||
ProtectionDomain protectionDomain, Class<?> contextClass) throws Exception {
|
||||
|
||||
|
|
@ -578,6 +578,16 @@ public class ReflectUtils {
|
|||
catch (InvocationTargetException ex) {
|
||||
throw new CodeGenerationException(ex.getTargetException());
|
||||
}
|
||||
catch (IllegalAccessException ex) {
|
||||
throw new CodeGenerationException(ex) {
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "ClassLoader mismatch for [" + contextClass.getName() +
|
||||
"]: JVM should be started with --add-opens=java.base/java.lang=ALL-UNNAMED " +
|
||||
"for ClassLoader.defineClass to be accessible on " + loader.getClass().getName();
|
||||
}
|
||||
};
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
throw new CodeGenerationException(ex);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue