Search in sources :

Example 36 with ClassReader

use of org.objectweb.asm.ClassReader in project spring-loaded by spring-projects.

the class TypeDescriptorExtractor method extract.

public TypeDescriptor extract(byte[] bytes, boolean isReloadableType) {
    ClassReader fileReader = new ClassReader(bytes);
    ExtractionVisitor extractionVisitor = new ExtractionVisitor(isReloadableType);
    fileReader.accept(extractionVisitor, 0);
    return extractionVisitor.getTypeDescriptor();
}
Also used : ClassReader(org.objectweb.asm.ClassReader)

Example 37 with ClassReader

use of org.objectweb.asm.ClassReader in project spring-loaded by spring-projects.

the class QuickVisitor method getImplementedInterfaces.

public static String[] getImplementedInterfaces(byte[] bytes) {
    ClassReader fileReader = new ClassReader(bytes);
    QuickVisitor1 qv = new QuickVisitor1();
    try {
        // TODO more flags to skip other things?
        fileReader.accept(qv, ClassReader.SKIP_FRAMES);
    } catch (EarlyExitException eee) {
    }
    return qv.interfaces;
}
Also used : ClassReader(org.objectweb.asm.ClassReader)

Example 38 with ClassReader

use of org.objectweb.asm.ClassReader in project spring-loaded by spring-projects.

the class SystemClassReflectionInvestigator method investigate.

public static int investigate(String slashedClassName, byte[] bytes, boolean print) {
    ClassReader fileReader = new ClassReader(bytes);
    RewriteClassAdaptor classAdaptor = new RewriteClassAdaptor(print);
    fileReader.accept(classAdaptor, ClassReader.SKIP_FRAMES);
    return classAdaptor.hitCount;
}
Also used : ClassReader(org.objectweb.asm.ClassReader)

Example 39 with ClassReader

use of org.objectweb.asm.ClassReader in project spring-loaded by spring-projects.

the class GroovyPlugin method modify.

public byte[] modify(String slashedClassName, ClassLoader classLoader, byte[] bytes) {
    if (allowCompilableCallSites) {
        return modifyDefineInClassLoaderForClassArtifacts(bytes);
    } else {
        // Deactivate compilation
        if (slashedClassName.equals("org/codehaus/groovy/runtime/callsite/GroovySunClassLoader")) {
            //		if (GlobalConfiguration.isRuntimeLogging && log.isLoggable(Level.INFO)) {
            //			log.info("loadtime modifying " + slashedClassName);
            //		}
            ClassReader cr = new ClassReader(bytes);
            NonFinalizer ca = new NonFinalizer("sunVM");
            //		ClassVisitingConstructorAppender ca = new ClassVisitingConstructorAppender("org/springsource/loaded/agent/SpringPlugin",
            //				"recordInstance");
            cr.accept(ca, 0);
            byte[] newbytes = ca.getBytes();
            return newbytes;
        } else {
            // must be the CallSiteGenerator
            ClassReader cr = new ClassReader(bytes);
            FalseReturner ca = new FalseReturner("isCompilable");
            cr.accept(ca, 0);
            byte[] newbytes = ca.getBytes();
            return newbytes;
        }
    }
}
Also used : ClassReader(org.objectweb.asm.ClassReader)

Example 40 with ClassReader

use of org.objectweb.asm.ClassReader in project spring-loaded by spring-projects.

the class PluginUtils method addInstanceTracking.

/**
	 * If adding instance tracking, the classToCall must implement:
	 * <tt>public static void recordInstance(Object obj)</tt>.
	 * 
	 * @param bytes the bytes for the class to which instance tracking is being added
	 * @param classToCall the class to call when a new instance is created
	 * @return the modified bytes for the class
	 */
public static byte[] addInstanceTracking(byte[] bytes, String classToCall) {
    ClassReader cr = new ClassReader(bytes);
    ClassVisitingConstructorAppender ca = new ClassVisitingConstructorAppender(classToCall, "recordInstance");
    cr.accept(ca, 0);
    byte[] newbytes = ca.getBytes();
    return newbytes;
}
Also used : ClassReader(org.objectweb.asm.ClassReader)

Aggregations

ClassReader (org.objectweb.asm.ClassReader)450 ClassWriter (org.objectweb.asm.ClassWriter)188 Test (org.junit.Test)134 IOException (java.io.IOException)78 InputStream (java.io.InputStream)76 TreeMap (java.util.TreeMap)59 ClassNode (org.objectweb.asm.tree.ClassNode)58 ClassVisitor (org.objectweb.asm.ClassVisitor)54 SemanticVersioningClassVisitor (org.apache.aries.versioning.utils.SemanticVersioningClassVisitor)53 HashSet (java.util.HashSet)39 ZipEntry (java.util.zip.ZipEntry)34 BinaryCompatibilityStatus (org.apache.aries.versioning.utils.BinaryCompatibilityStatus)32 ZipFile (java.util.zip.ZipFile)29 InvocationTargetException (java.lang.reflect.InvocationTargetException)26 Method (java.lang.reflect.Method)26 OuterClass (com.android.tools.layoutlib.create.dataclass.OuterClass)23 InnerClass (com.android.tools.layoutlib.create.dataclass.OuterClass.InnerClass)23 PrintWriter (java.io.PrintWriter)23 MethodVisitor (org.objectweb.asm.MethodVisitor)23 MethodNode (org.objectweb.asm.tree.MethodNode)21