Search in sources :

Example 31 with ClassReader

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

the class SpringLoadedTests method print.

protected void print(byte[] classdata) {
    ClassReader reader = new ClassReader(classdata);
    reader.accept(new ClassPrinter(System.out), 0);
}
Also used : ClassReader(org.objectweb.asm.ClassReader) ClassPrinter(org.springsource.loaded.test.infra.ClassPrinter)

Example 32 with ClassReader

use of org.objectweb.asm.ClassReader in project bazel by bazelbuild.

the class JavacTurbine method processBytecode.

/**
   * Remove code attributes and private members.
   *
   * <p>Most code will already have been removed after parsing, but the bytecode will still contain
   * e.g. lowered class and instance initializers.
   */
private static byte[] processBytecode(byte[] bytes) {
    ClassWriter cw = new ClassWriter(0);
    new ClassReader(bytes).accept(new PrivateMemberPruner(cw), ClassReader.SKIP_CODE | ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
    return cw.toByteArray();
}
Also used : ClassReader(org.objectweb.asm.ClassReader) ClassWriter(org.objectweb.asm.ClassWriter)

Example 33 with ClassReader

use of org.objectweb.asm.ClassReader in project auto by google.

the class AbstractMethodLister method abstractNoArgMethodsX.

private ImmutableList<String> abstractNoArgMethodsX() throws IOException {
    ClassReader classReader = new ClassReader(inputStream);
    RecordingClassVisitor classVisitor = new RecordingClassVisitor();
    classReader.accept(classVisitor, 0);
    return classVisitor.abstractNoArgMethods.build();
}
Also used : ClassReader(org.objectweb.asm.ClassReader)

Example 34 with ClassReader

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

the class TypeRewriter method rewrite.

public static byte[] rewrite(ReloadableType rtype, byte[] bytes) {
    ClassReader fileReader = new ClassReader(bytes);
    RewriteClassAdaptor classAdaptor = new RewriteClassAdaptor(rtype);
    fileReader.accept(classAdaptor, 0);
    return classAdaptor.getBytes();
}
Also used : ClassReader(org.objectweb.asm.ClassReader)

Example 35 with ClassReader

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

the class InterfaceExtractor method extract.

public byte[] extract(byte[] classbytes, TypeDescriptor typeDescriptor) {
    ClassReader fileReader = new ClassReader(classbytes);
    ExtractorVisitor extractorVisitor = new ExtractorVisitor(typeDescriptor);
    fileReader.accept(extractorVisitor, 0);
    return extractorVisitor.getBytes();
}
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