< prev index next >

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

Print this page

        

*** 25,42 **** 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 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(); /** <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 --- 25,44 ---- package jdk.internal.reflect; import java.security.AccessController; import java.security.PrivilegedAction; ! 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 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,68 **** new PrivilegedAction<ClassLoader>() { public ClassLoader run() { return new DelegatingClassLoader(parentClassLoader); } }); ! return unsafe.defineClass(name, bytes, off, len, newLoader, null); } } // NOTE: this class's name and presence are known to the virtual --- 60,70 ---- new PrivilegedAction<ClassLoader>() { public ClassLoader run() { return new DelegatingClassLoader(parentClassLoader); } }); ! return JLA.defineClass(newLoader, name, bytes, null, "__ClassDefiner__"); } } // NOTE: this class's name and presence are known to the virtual
< prev index next >