Try loadClass on LinkageError in case of ClassLoader mismatch
See gh-34677
This commit is contained in:
parent
26869b0e4c
commit
7f2c1f447f
|
@ -527,6 +527,16 @@ public class ReflectUtils {
|
|||
c = lookup.defineClass(b);
|
||||
}
|
||||
catch (LinkageError | IllegalAccessException ex) {
|
||||
if (ex instanceof LinkageError) {
|
||||
// Could be a ClassLoader mismatch with the class pre-existing in a
|
||||
// parent ClassLoader -> try loadClass before giving up completely.
|
||||
try {
|
||||
c = contextClass.getClassLoader().loadClass(className);
|
||||
}
|
||||
catch (ClassNotFoundException cnfe) {
|
||||
}
|
||||
}
|
||||
if (c == null) {
|
||||
throw new CodeGenerationException(ex) {
|
||||
@Override
|
||||
public String getMessage() {
|
||||
|
@ -537,6 +547,7 @@ public class ReflectUtils {
|
|||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
throw new CodeGenerationException(ex);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue