src/share/classes/java/lang/ClassLoader.java

Print this page

        

*** 49,59 **** import java.util.Map; import java.util.Vector; import java.util.Hashtable; import java.util.WeakHashMap; import java.util.concurrent.ConcurrentHashMap; - import sun.misc.ClassFileTransformer; import sun.misc.CompoundEnumeration; import sun.misc.Resource; import sun.misc.URLClassPath; import sun.misc.VM; import sun.reflect.Reflection; --- 49,58 ----
*** 667,711 **** source = cs.getLocation().toString(); } return source; } - 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; - } - private void postDefineClass(Class<?> c, ProtectionDomain pd) { if (pd.getCodeSource() != null) { Certificate certs[] = pd.getCodeSource().getCertificates(); if (certs != null) --- 666,675 ----
*** 781,801 **** protected final Class<?> defineClass(String name, byte[] b, int off, int len, ProtectionDomain protectionDomain) throws ClassFormatError { protectionDomain = preDefineClass(name, protectionDomain); - - Class<?> c = null; String source = defineClassSourceLocation(protectionDomain); ! ! try { ! c = defineClass1(name, b, off, len, protectionDomain, source); ! } catch (ClassFormatError cfe) { ! c = defineTransformedClass(name, b, off, len, protectionDomain, cfe, ! source); ! } ! postDefineClass(c, protectionDomain); return c; } /** --- 745,756 ---- protected final Class<?> defineClass(String name, byte[] b, int off, int len, ProtectionDomain protectionDomain) throws ClassFormatError { protectionDomain = preDefineClass(name, protectionDomain); String source = defineClassSourceLocation(protectionDomain); ! Class<?> c = defineClass1(name, b, off, len, protectionDomain, source); postDefineClass(c, protectionDomain); return c; } /**
*** 879,902 **** return defineClass(name, tb, 0, len, protectionDomain); } } protectionDomain = preDefineClass(name, protectionDomain); - - Class<?> c = null; String source = defineClassSourceLocation(protectionDomain); ! ! try { ! c = defineClass2(name, b, b.position(), len, protectionDomain, ! source); ! } catch (ClassFormatError cfe) { ! byte[] tb = new byte[len]; ! b.get(tb); // get bytes out of byte buffer. ! c = defineTransformedClass(name, tb, 0, len, protectionDomain, cfe, ! source); ! } ! postDefineClass(c, protectionDomain); return c; } private native Class<?> defineClass0(String name, byte[] b, int off, int len, --- 834,845 ---- return defineClass(name, tb, 0, len, protectionDomain); } } protectionDomain = preDefineClass(name, protectionDomain); String source = defineClassSourceLocation(protectionDomain); ! Class<?> c = defineClass2(name, b, b.position(), len, protectionDomain, source); postDefineClass(c, protectionDomain); return c; } private native Class<?> defineClass0(String name, byte[] b, int off, int len,