< prev index next >

src/java.base/share/classes/jdk/internal/reflect/ClassDefiner.java

Print this page

        

@@ -25,18 +25,20 @@
 
 package jdk.internal.reflect;
 
 import java.security.AccessController;
 import java.security.PrivilegedAction;
-import jdk.internal.misc.Unsafe;
 
-/** Utility class which assists in calling Unsafe.defineClass() by
+import jdk.internal.misc.JavaLangAccess;
+import jdk.internal.misc.SharedSecrets;
+
+/** Utility class which assists in calling defineClass() by
     creating a new class loader which delegates to the one needed in
     order for proper resolution of the given bytecodes to occur. */
 
 class ClassDefiner {
-    static final Unsafe unsafe = Unsafe.getUnsafe();
+    static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
 
     /** <P> We define generated code into a new class loader which
       delegates to the defining loader of the target class. It is
       necessary for the VM to be able to resolve references to the
       target class from the generated bytecodes, which could not occur

@@ -58,11 +60,11 @@
             new PrivilegedAction<ClassLoader>() {
                 public ClassLoader run() {
                         return new DelegatingClassLoader(parentClassLoader);
                     }
                 });
-        return unsafe.defineClass(name, bytes, off, len, newLoader, null);
+        return JLA.defineClass(newLoader, name, bytes, null, "__ClassDefiner__");
     }
 }
 
 
 // NOTE: this class's name and presence are known to the virtual
< prev index next >