Java 类sun.misc.ClassFileTransformer 实例源码

项目:VarJ    文件:ClassLoader.java   
private Class defineTransformedClass(String name, byte[] b, int off, int len,
                 ProtectionDomain protectionDomain,
                 ClassFormatError cfe, String source)
     throws ClassFormatError
   {
       // Class format error - try to transform the bytecode and
       // define the class again
       //
       Object[] transformers = ClassFileTransformer.getTransformers();
Class c = null;

for (int i = 0; transformers != null && i < transformers.length; i++) {
    try {
      // Transform byte code using transformer
      byte[] tb = ((ClassFileTransformer) transformers[i]).transform(b, off, len);
      c = defineClass1(name, tb, 0, tb.length, protectionDomain, source);
      break;
    } catch (ClassFormatError cfe2) {
      // If ClassFormatError occurs, try next transformer
    }
}

// Rethrow original ClassFormatError if unable to transform
// bytecode to well-formed
//
if (c == null)
    throw cfe;

return c;
   }
项目:jdk-1.7-annotated    文件:ClassLoader.java   
private Class defineTransformedClass(String name, byte[] b, int off, int len,
                                     ProtectionDomain pd,
                                     ClassFormatError cfe, String source)
  throws ClassFormatError
{
    // Class format error - try to transform the bytecode and
    // define the class again
    //
    ClassFileTransformer[] transformers =
        ClassFileTransformer.getTransformers();
    Class c = null;

    if (transformers != null) {
        for (ClassFileTransformer transformer : transformers) {
            try {
                // Transform byte code using transformer
                byte[] tb = transformer.transform(b, off, len);
                c = defineClass1(name, tb, 0, tb.length,
                                 pd, source);
                break;
            } catch (ClassFormatError cfe2)     {
                // If ClassFormatError occurs, try next transformer
            }
        }
    }

    // Rethrow original ClassFormatError if unable to transform
    // bytecode to well-formed
    //
    if (c == null)
        throw cfe;

    return c;
}
项目:jdk7-jdk    文件:ClassLoader.java   
private Class defineTransformedClass(String name, byte[] b, int off, int len,
                                     ProtectionDomain pd,
                                     ClassFormatError cfe, String source)
  throws ClassFormatError
{
    // Class format error - try to transform the bytecode and
    // define the class again
    //
    ClassFileTransformer[] transformers =
        ClassFileTransformer.getTransformers();
    Class c = null;

    if (transformers != null) {
        for (ClassFileTransformer transformer : transformers) {
            try {
                // Transform byte code using transformer
                byte[] tb = transformer.transform(b, off, len);
                c = defineClass1(name, tb, 0, tb.length,
                                 pd, source);
                break;
            } catch (ClassFormatError cfe2)     {
                // If ClassFormatError occurs, try next transformer
            }
        }
    }

    // Rethrow original ClassFormatError if unable to transform
    // bytecode to well-formed
    //
    if (c == null)
        throw cfe;

    return c;
}
项目:openjdk-source-code-learn    文件:ClassLoader.java   
private Class defineTransformedClass(String name, byte[] b, int off, int len,
                                     ProtectionDomain pd,
                                     ClassFormatError cfe, String source)
  throws ClassFormatError
{
    // Class format error - try to transform the bytecode and
    // define the class again
    //
    ClassFileTransformer[] transformers =
        ClassFileTransformer.getTransformers();
    Class c = null;

    if (transformers != null) {
        for (ClassFileTransformer transformer : transformers) {
            try {
                // Transform byte code using transformer
                byte[] tb = transformer.transform(b, off, len);
                c = defineClass1(name, tb, 0, tb.length,
                                 pd, source);
                break;
            } catch (ClassFormatError cfe2)     {
                // If ClassFormatError occurs, try next transformer
            }
        }
    }

    // Rethrow original ClassFormatError if unable to transform
    // bytecode to well-formed
    //
    if (c == null)
        throw cfe;

    return c;
}
项目:openjdk-jdk7u-jdk    文件:ClassLoader.java   
private Class defineTransformedClass(String name, byte[] b, int off, int len,
                                     ProtectionDomain pd,
                                     ClassFormatError cfe, String source)
  throws ClassFormatError
{
    // Class format error - try to transform the bytecode and
    // define the class again
    //
    ClassFileTransformer[] transformers =
        ClassFileTransformer.getTransformers();
    Class c = null;

    if (transformers != null) {
        for (ClassFileTransformer transformer : transformers) {
            try {
                // Transform byte code using transformer
                byte[] tb = transformer.transform(b, off, len);
                c = defineClass1(name, tb, 0, tb.length,
                                 pd, source);
                break;
            } catch (ClassFormatError cfe2)     {
                // If ClassFormatError occurs, try next transformer
            }
        }
    }

    // Rethrow original ClassFormatError if unable to transform
    // bytecode to well-formed
    //
    if (c == null)
        throw cfe;

    return c;
}
项目:openjdk-icedtea7    文件:ClassLoader.java   
private Class defineTransformedClass(String name, byte[] b, int off, int len,
                                     ProtectionDomain pd,
                                     ClassFormatError cfe, String source)
  throws ClassFormatError
{
    // Class format error - try to transform the bytecode and
    // define the class again
    //
    ClassFileTransformer[] transformers =
        ClassFileTransformer.getTransformers();
    Class c = null;

    if (transformers != null) {
        for (ClassFileTransformer transformer : transformers) {
            try {
                // Transform byte code using transformer
                byte[] tb = transformer.transform(b, off, len);
                c = defineClass1(name, tb, 0, tb.length,
                                 pd, source);
                break;
            } catch (ClassFormatError cfe2)     {
                // If ClassFormatError occurs, try next transformer
            }
        }
    }

    // Rethrow original ClassFormatError if unable to transform
    // bytecode to well-formed
    //
    if (c == null)
        throw cfe;

    return c;
}