Package org.objectweb.asm

Examples of org.objectweb.asm.ClassReader.accept()


    if (args[i].endsWith(".class")) {
      cr = new ClassReader(new FileInputStream(args[i]));
    } else {
      cr = new ClassReader(args[i]);
    }
    cr.accept(new ASMifierClassVisitor(
      new PrintWriter(System.out)), getDefaultAttributes(), skipDebug);
  }

  private static void printUsage () {
    System.err.println("Prints the ASM code to generate the given class.");
View Full Code Here


public class Analysis implements Constants {
 
  public static void main (String[] args) throws Exception {
    ClassReader cr = new ClassReader("Analysis");
    TreeClassAdapter ca = new TreeClassAdapter(null);
    cr.accept(ca, true);
   
    List methods = ca.classNode.methods;
    for (int i = 0; i < methods.size(); ++i) {
      MethodNode method = (MethodNode)methods.get(i);
      if (method.instructions.size() > 0) {
View Full Code Here

  }
 
  public void testAnalysis () throws Exception {
    ClassReader cr = new ClassReader(new URL(className).openStream());
    TreeClassAdapter ca = new TreeClassAdapter(null);
    cr.accept(ca, false);
   
    List methods = ca.classNode.methods;
    for (int i = 0; i < methods.size(); ++i) {
      MethodNode method = (MethodNode)methods.get(i);
     
View Full Code Here

  }
 
  public void testAnalysis () throws Exception {
    ClassReader cr = new ClassReader(new URL(className).openStream());
    TreeClassAdapter ca = new TreeClassAdapter(null);
    cr.accept(ca, false);
   
    List methods = ca.classNode.methods;
    for (int i = 0; i < methods.size(); ++i) {
      MethodNode method = (MethodNode)methods.get(i);
     
View Full Code Here

   
    StringWriter sw = new StringWriter();
    ASMifierClassVisitor cv = new ASMifierClassVisitor( new PrintWriter( sw));
   
    ClassReader cr = new ClassReader( classData);
    cr.accept(cv, PrintClassVisitor.getDefaultAttributes(), false);

    String name = classUrl.getFile();
    String generated = sw.toString();
   
    String cname = name.substring( name.lastIndexOf( '/')+1, name.length()-".class".length())+"Dump";
View Full Code Here

 
  private static String traceBytecode( byte[] classData) {
    StringWriter sw = new StringWriter();
    ClassReader cr = new ClassReader( classData);
    // cr.accept( new TraceClassVisitor( cw, new PrintWriter( System.out)),
    cr.accept( new TraceClassVisitor( null, new PrintWriter( sw)), Attributes.getDefaultAttributes(), false);
    return sw.toString();
  }

  private Class loadClass(String className, byte[] bytecode) throws ClassNotFoundException {
    return new TestClassLoader( className, bytecode).loadClass( className);
View Full Code Here

  public void testRoundtrip() throws Exception {
    byte[] classData = getCode( new URL( className).openStream());
   
    ClassReader cr = new ClassReader( classData);
    ClassWriter cw = new ClassWriter( false, false);
    cr.accept(cw, Attributes.getDefaultAttributes(), false);
    byte[] newData = cw.toByteArray();

    try {
    assertTrue( Arrays.equals( classData, newData));
     
View Full Code Here

  }
 
  private static void traceBytecode( byte[] classData, PrintWriter pw) {
    ClassReader cr = new ClassReader( classData);
    // cr.accept( new TraceClassVisitor( cw, new PrintWriter( System.out)),
    cr.accept( new TraceClassVisitor( null, pw), Attributes.getDefaultAttributes(), false);
  }

  private static byte[] getCode( InputStream is) throws IOException {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    byte[] buff = new byte[ 1024];
View Full Code Here

        // invalid classfile format is indicated by a
        // random runtime exception rather than something
        // indicative of the real problem.
        try {
            ClassNode cn = new ClassNode();
            classReader.accept(cn, 0);
            return cn;
        } catch (RuntimeException e) {
            throw new InvalidClassFileFormatException(descriptor, entry, e);
        }
    }
View Full Code Here

    public BytecodeChecker(byte[] buffer) {
        // run a pass over the bytecode to identify the interfaces
        ClassReader cr = new ClassReader(buffer);
        adapter = new ClassStructureAdapter();
        cr.accept(adapter, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
    }

    public boolean isInterface() {
        return adapter.isInterface();
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.