diff options
author | Andy Clement <aclement@pivotal.io> | 2019-01-11 15:49:49 -0800 |
---|---|---|
committer | Andy Clement <aclement@pivotal.io> | 2019-01-11 15:49:49 -0800 |
commit | a11b07517aa85fb5c4e856f475050a4136ed36e6 (patch) | |
tree | 2c0e068006df5cca1cfd80262ba635e8a8096c74 | |
parent | 5f594722aa770bd1cc763a313336c06bc19a8f7a (diff) | |
download | aspectj-a11b07517aa85fb5c4e856f475050a4136ed36e6.tar.gz aspectj-a11b07517aa85fb5c4e856f475050a4136ed36e6.zip |
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
-rw-r--r-- | loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java index c4c1ba3ae..f67b0f3ad 100644 --- a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java +++ b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java @@ -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); |