src/java.base/share/classes/sun/invoke/anon/AnonymousClassLoader.java

Print this page
rev 12972 : 8140606: Update library code to use internal Unsafe
Reviewed-by: duke

*** 76,86 **** // Privileged constructor. private AnonymousClassLoader(Class<?> hostClass) { this.hostClass = hostClass; } ! public static AnonymousClassLoader make(sun.misc.Unsafe unsafe, Class<?> hostClass) { if (unsafe == null) throw new NullPointerException(); return new AnonymousClassLoader(hostClass); } public Class<?> loadClass(byte[] classFile) { --- 76,86 ---- // Privileged constructor. private AnonymousClassLoader(Class<?> hostClass) { this.hostClass = hostClass; } ! public static AnonymousClassLoader make(jdk.internal.misc.Unsafe unsafe, Class<?> hostClass) { if (unsafe == null) throw new NullPointerException(); return new AnonymousClassLoader(hostClass); } public Class<?> loadClass(byte[] classFile) {
*** 187,203 **** hostClass.getProtectionDomain()); } private static int fakeNameCounter = 99999; // ignore two warnings on this line: ! private static sun.misc.Unsafe unsafe = sun.misc.Unsafe.getUnsafe(); // preceding line requires that this class be on the boot class path private static final Method defineAnonymousClass; static { Method dac = null; ! Class<? extends sun.misc.Unsafe> unsafeClass = unsafe.getClass(); try { dac = unsafeClass.getMethod("defineAnonymousClass", Class.class, byte[].class, Object[].class); --- 187,203 ---- hostClass.getProtectionDomain()); } private static int fakeNameCounter = 99999; // ignore two warnings on this line: ! private static jdk.internal.misc.Unsafe unsafe = jdk.internal.misc.Unsafe.getUnsafe(); // preceding line requires that this class be on the boot class path private static final Method defineAnonymousClass; static { Method dac = null; ! Class<? extends jdk.internal.misc.Unsafe> unsafeClass = unsafe.getClass(); try { dac = unsafeClass.getMethod("defineAnonymousClass", Class.class, byte[].class, Object[].class);