Pārlūkot izejas kodu

On JDK11 call the defineClass variant with a ProtectionDomain param

This alters the defineClass used when loadtime weaving and defining
'extra' classes (e.g. closures). This change causes us to call
the defineClass() method variant on ClassLoader that takes a
protection domain, so it should share the same protection domain as
the class for which the extra class was generated.

Issue: https://bugs.eclipse.org/bugs/show_bug.cgi?id=542421
tags/V1_9_3RC1
Andy Clement pirms 5 gadiem
vecāks
revīzija
a11b07517a

+ 4
- 4
loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java Parādīt failu

@@ -1054,11 +1054,11 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
private static synchronized void initializeForJava11() {
if (initializedForJava11) return;
try {
// MethodType defineClassMethodType = MethodType.methodType(Class.class, new Class[]{String.class, byte[].class, int.class, int.class});
// MethodType defineClassMethodType = MethodType.methodType(Class.class, new Class[]{String.class, byte[].class, int.class, int.class, ProtectionDomain.class});
Class<?> methodType_Class = Class.forName("java.lang.invoke.MethodType");
Method methodTypeMethodOnMethodTypeClass = methodType_Class.getDeclaredMethod("methodType", Class.class,Class[].class);
methodTypeMethodOnMethodTypeClass.setAccessible(true);
Object defineClassMethodType = methodTypeMethodOnMethodTypeClass.invoke(null, Class.class, new Class[] {String.class,byte[].class,int.class,int.class});
Object defineClassMethodType = methodTypeMethodOnMethodTypeClass.invoke(null, Class.class, new Class[] {String.class,byte[].class,int.class,int.class,ProtectionDomain.class});

// MethodHandles.Lookup methodHandlesLookup = MethodHandles.lookup();
Class<?> methodHandles_Class = Class.forName("java.lang.invoke.MethodHandles");
@@ -1099,9 +1099,9 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
if (!initializedForJava11) {
initializeForJava11();
}
// Do this: clazz = defineClassMethodHandle.bindTo(loader).invokeWithArguments(name, bytes, 0, bytes.length);
// Do this: clazz = defineClassMethodHandle.bindTo(loader).invokeWithArguments(name, bytes, 0, bytes.length, protectionDomain);
Object o = bindTo_Method.invoke(defineClassMethodHandle,loader);
clazz = invokeWithArguments_Method.invoke(o, new Object[] {new Object[] {name, bytes, 0, bytes.length}});
clazz = invokeWithArguments_Method.invoke(o, new Object[] {new Object[] {name, bytes, 0, bytes.length, protectionDomain}});
} catch (Throwable t) {
t.printStackTrace(System.err);

Notiek ielāde…
Atcelt
Saglabāt