Home » openjdk-7 » sun » reflect » [javadoc | source]
sun.reflect
class: ClassDefiner [javadoc | source]
java.lang.Object
   sun.reflect.ClassDefiner
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.
Field Summary
static final  Unsafe unsafe     
Method from sun.reflect.ClassDefiner Summary:
defineClass
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from sun.reflect.ClassDefiner Detail:
 static Class defineClass(String name,
    byte[] bytes,
    int off,
    int len,
    ClassLoader parentClassLoader) 

    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 if the generated code was loaded into the bootstrap class loader.

    There are two primary reasons for creating a new loader instead of defining these bytecodes directly into the defining loader of the target class: first, it avoids any possible security risk of having these bytecodes in the same loader. Second, it allows the generated bytecodes to be unloaded earlier than would otherwise be possible, decreasing run-time footprint.