Package nginx.clojure.asm

Examples of nginx.clojure.asm.ClassReader


       
   
    }

    static byte[] instrumentClass(MethodDatabase db, byte[] data, boolean check) {
        ClassReader r = new ClassReader(data);
        ClassWriter cw = new DBClassWriter(db, r);
        ClassVisitor cv = check ? new CheckClassAdapter(cw) : cw;
        ClassEntry ce = MethodDatabaseUtil.buildClassEntryFamily(db, r);
        if(db.shouldIgnore(r.getClassName())) {
            return null;
        }
        db.trace("TRANSFORM: %s", r.getClassName());
        InstrumentClass ic = new InstrumentClass(r.getClassName(), ce, cv, db, false);
        r.accept(ic, ClassReader.SKIP_FRAMES);
        return cw.toByteArray();
    }
View Full Code Here


      if (SuspendMethodTracer.quiteFlags.get()) {
        return classfileBuffer;
      }
      try {
       
        ClassReader cr = new ClassReader(classfileBuffer);
        ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_FRAMES) {
          @Override
          protected String getCommonSuperClass(String type1, String type2) {
            return db.getCommonSuperClass(type1, type2);
          }
        };
       
        ClassEntry ce = MethodDatabaseUtil.buildClassEntryFamily(db, cr);
//        if (className.startsWith("sun/launcher/")
//            || className.startsWith("clojure/asm")
//            || className.startsWith("org/objectweb/asm/")
//            || className.startsWith("clojure/asm")
//            || className.startsWith("org/junit")
////            || className.startsWith("clojure/main")
////            || className.startsWith("clojure/lang")
//            || className.startsWith("sun/misc/ClassFileTransformer")
//            || className.startsWith("nginx/clojure/asm")
//            || className.startsWith("nginx/clojure/wave")
//            || className.startsWith("java/util/ArrayList")
//            || className.startsWith("org/eclipse/jetty/server/")
//            || className.startsWith("clojure/lang/Compiler")
//            || className.startsWith("java/net/URLClassLoader")
//            || className.startsWith("java/io/PrintStream")
//            || className.startsWith("java/util/concurrent/ConcurrentHashMap")
//            || className.startsWith("java/util/concurrent/atomic/AtomicBoolean")
//            || className.startsWith("java/")
//            || className.startsWith("sun/")
//            || className.startsWith("com/sun/")
//            || className.startsWith("org/eclipse/jdt/")
//            || className.endsWith("ClassLoader")
//            || className.startsWith("clojure/lang/PersistentHashMap")
//            || className.startsWith("clojure/lang/Keyword")
//            || className.startsWith("clojure/lang/Symbol")
//            || className.startsWith("clojure/lang/Namespace")
//            || className.startsWith("clojure/lang/Persistent")
//            || className.startsWith("java/lang"))
        if (db.shouldIgnore(className)){
          db.debug("skip class %s", className);
          return classfileBuffer;
        }
        db.debug("loading class %s", className);
//        ClassVisitor cv = db.isVerbose() ?  new TraceClassVisitor(cw, new PrintWriter(System.out)) : cw;
        ClassVisitor cv = new ClassVisitor(Opcodes.ASM4, cw) {
          @Override
          public MethodVisitor visitMethod(int access, String name,
              String desc, String signature, String[] exceptions) {
            MethodVisitor mv = super.visitMethod(access, name,
                desc, signature, exceptions);
            if ( (Opcodes.ACC_NATIVE & access) != 0
                ||  (Opcodes.ACC_ABSTRACT & access) != 0
//                || name.startsWith("<cinit>")
                ) {
              db.debug("skip native or abstract method: %s.%s%s", className, name, desc);
              return mv;
            }
            return new JSRInlinerAdapter(new SuspendMethodTracerAdvice(db, className, mv, access, name, desc), access, name, desc, signature, exceptions);
          }
        };

        cr.accept(cv, ClassReader.EXPAND_FRAMES);
        byte[] rt = cw.toByteArray();
       
        if (db.isDump()) {
          File wavedFile = new File(new File(db.getDumpDir() + "/waved-by-tool"), className + ".class");
                    wavedFile.getParentFile().mkdirs();
View Full Code Here

            System.err.println("Verifies the given class.");
            System.err.println("Usage: CheckClassAdapter "
                    + "<fully qualified class name or class file name>");
            return;
        }
        ClassReader cr;
        if (args[0].endsWith(".class")) {
            cr = new ClassReader(new FileInputStream(args[0]));
        } else {
            cr = new ClassReader(args[0]);
        }

        verify(cr, false, new PrintWriter(System.err));
    }
View Full Code Here

                    .println("Prints a disassembled view of the given class.");
            System.err.println("Usage: Textifier [-debug] "
                    + "<fully qualified class name or class file name>");
            return;
        }
        ClassReader cr;
        if (args[i].endsWith(".class") || args[i].indexOf('\\') > -1
                || args[i].indexOf('/') > -1) {
            cr = new ClassReader(new FileInputStream(args[i]));
        } else {
            cr = new ClassReader(args[i]);
        }
        cr.accept(new TraceClassVisitor(new PrintWriter(System.out)), flags);
    }
View Full Code Here

                    .println("Prints the ASM code to generate the given class.");
            System.err.println("Usage: ASMifier [-debug] "
                    + "<fully qualified class name or class file name>");
            return;
        }
        ClassReader cr;
        if (args[i].endsWith(".class") || args[i].indexOf('\\') > -1
                || args[i].indexOf('/') > -1) {
            cr = new ClassReader(new FileInputStream(args[i]));
        } else {
            cr = new ClassReader(args[i]);
        }
        cr.accept(new TraceClassVisitor(null, new ASMifier(), new PrintWriter(
                System.out)), flags);
    }
View Full Code Here

    }
   
    public CheckInstrumentationVisitor checkFileAndClose(InputStream is, String name) {
        try {
            try {
                ClassReader r = new ClassReader(is);

                CheckInstrumentationVisitor civ = new CheckInstrumentationVisitor();
                r.accept(civ, ClassReader.SKIP_DEBUG|ClassReader.SKIP_FRAMES|ClassReader.SKIP_CODE);
               
                return civ;
            } finally {
                is.close();
            }
View Full Code Here

          }
        });
       
        InputStream in = BlockingTest.class.getResourceAsStream("BlockingTest.class");
        try {
            ClassReader r = new ClassReader(in);
            ClassWriter cw = new ClassWriter(0);
            InstrumentClass ic = new InstrumentClass(r.getClassName(), MethodDatabaseUtil.buildClassEntryFamily(db, r), cw, db, true);
            r.accept(ic, ClassReader.SKIP_FRAMES);
        } finally {
            in.close();
        }
       
        assertTrue("Expected messages not generated: "+msgs.toString(), msgs.isEmpty());
View Full Code Here

TOP

Related Classes of nginx.clojure.asm.ClassReader

Copyright © 2018 www.massapicom. 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.