Fixes #2913 - ClassNotFoundException: sun.reflect.Reflection with JDK 11

Another update after review.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2018-09-19 13:50:33 +02:00
parent 9a9a52b960
commit bae502681c
1 changed files with 4 additions and 5 deletions

View File

@ -2594,10 +2594,9 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
// classloader, or a parent of it, as required by the javadoc specification. // classloader, or a parent of it, as required by the javadoc specification.
// Wrap so that only Jetty code requires the "createSecurityManager" permission. // Wrap so that only Jetty code requires the "createSecurityManager" permission.
Caller caller = AccessController.doPrivileged((PrivilegedAction<Caller>)Caller::new);
Class<?> callerClass = caller.getCallerClass(2);
boolean ok = false; boolean ok = false;
ClassLoader callerLoader = callerClass == null ? null : callerClass.getClassLoader(); Caller caller = AccessController.doPrivileged((PrivilegedAction<Caller>)Caller::new);
ClassLoader callerLoader = caller.getCallerClassLoader(2);
while (!ok && callerLoader != null) while (!ok && callerLoader != null)
{ {
if (callerLoader == _classLoader) if (callerLoader == _classLoader)
@ -3081,14 +3080,14 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
private static class Caller extends SecurityManager private static class Caller extends SecurityManager
{ {
public Class<?> getCallerClass(int depth) public ClassLoader getCallerClassLoader(int depth)
{ {
if (depth < 0) if (depth < 0)
return null; return null;
Class<?>[] classContext = getClassContext(); Class<?>[] classContext = getClassContext();
if (classContext.length <= depth) if (classContext.length <= depth)
return null; return null;
return classContext[depth]; return classContext[depth].getClassLoader();
} }
} }
} }