8009857: Problem with plugin
Reviewed-by: jdn, mchung
This commit is contained in:
parent
d059d367eb
commit
3a4936696c
@ -46,8 +46,28 @@ import sun.misc.IOUtils;
|
|||||||
|
|
||||||
|
|
||||||
class Trampoline {
|
class Trampoline {
|
||||||
|
static {
|
||||||
|
if (Trampoline.class.getClassLoader() == null) {
|
||||||
|
throw new Error(
|
||||||
|
"Trampoline must not be defined by the bootstrap classloader");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ensureInvocableMethod(Method m)
|
||||||
|
throws InvocationTargetException
|
||||||
|
{
|
||||||
|
Class<?> clazz = m.getDeclaringClass();
|
||||||
|
if (clazz.equals(AccessController.class) ||
|
||||||
|
clazz.equals(Method.class) ||
|
||||||
|
clazz.getName().startsWith("java.lang.invoke."))
|
||||||
|
throw new InvocationTargetException(
|
||||||
|
new UnsupportedOperationException("invocation not supported"));
|
||||||
|
}
|
||||||
|
|
||||||
private static Object invoke(Method m, Object obj, Object[] params)
|
private static Object invoke(Method m, Object obj, Object[] params)
|
||||||
throws InvocationTargetException, IllegalAccessException {
|
throws InvocationTargetException, IllegalAccessException
|
||||||
|
{
|
||||||
|
ensureInvocableMethod(m);
|
||||||
return m.invoke(obj, params);
|
return m.invoke(obj, params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -251,16 +271,6 @@ public final class MethodUtil extends SecureClassLoader {
|
|||||||
*/
|
*/
|
||||||
public static Object invoke(Method m, Object obj, Object[] params)
|
public static Object invoke(Method m, Object obj, Object[] params)
|
||||||
throws InvocationTargetException, IllegalAccessException {
|
throws InvocationTargetException, IllegalAccessException {
|
||||||
if (m.getDeclaringClass().equals(AccessController.class) ||
|
|
||||||
(m.getDeclaringClass().equals(java.lang.invoke.MethodHandles.class)
|
|
||||||
&& m.getName().equals("lookup")) ||
|
|
||||||
(m.getDeclaringClass().equals(java.lang.invoke.MethodHandles.Lookup.class)
|
|
||||||
&& (m.getName().startsWith("find") ||
|
|
||||||
m.getName().startsWith("bind") ||
|
|
||||||
m.getName().startsWith("unreflect"))) ||
|
|
||||||
m.getDeclaringClass().equals(Method.class))
|
|
||||||
throw new InvocationTargetException(
|
|
||||||
new UnsupportedOperationException("invocation not supported"));
|
|
||||||
try {
|
try {
|
||||||
return bounce.invoke(null, new Object[] {m, obj, params});
|
return bounce.invoke(null, new Object[] {m, obj, params});
|
||||||
} catch (InvocationTargetException ie) {
|
} catch (InvocationTargetException ie) {
|
||||||
@ -293,10 +303,10 @@ public final class MethodUtil extends SecureClassLoader {
|
|||||||
Method.class, Object.class, Object[].class
|
Method.class, Object.class, Object[].class
|
||||||
};
|
};
|
||||||
Method b = t.getDeclaredMethod("invoke", types);
|
Method b = t.getDeclaredMethod("invoke", types);
|
||||||
((AccessibleObject)b).setAccessible(true);
|
b.setAccessible(true);
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new InternalError("bouncer cannot be found", e);
|
throw new InternalError("bouncer cannot be found", e);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user