Java 类org.objectweb.asm.ClassAdapter 实例源码

项目:asup    文件:ASMProgramLoader.java   
private void completeClass(WovenClass wovenClass) {

//      System.out.println("Woven: "+wovenClass);

        ClassReader cr = new ClassReader(wovenClass.getBytes());

        LabelAnalyzer labelAnalyzer = new LabelAnalyzer();
        cr.accept(labelAnalyzer, 0);

        Map<String, Label> tag2Label = labelAnalyzer.getTag2Label();
/*      for (Entry<String, Label> entry : tag2Label.entrySet()) {
            System.out.println(entry.getKey() + "=" + entry.getValue() + "(" + entry.getValue().info + ")");
        }*/

        ClassWriter cw = new ClassWriter(cr, 0);
        ClassAdapter ca = new JumpTransformer(cw, wovenClass.getClassName().replace(".", "/"), tag2Label);
        cr.accept(ca, 0);

        wovenClass.setBytes(cw.toByteArray());
    }
项目:annotation-tools    文件:LocalVariablesSorterTest.java   
public void test() throws Exception {
    ClassReader cr = new ClassReader(is);
    ClassWriter cw = new ClassWriter(true, true);
    cr.accept(new ClassAdapter(cw) {
        public MethodVisitor visitMethod(
            int access,
            String name,
            String desc,
            String signature,
            String[] exceptions)
        {
            return new LocalVariablesSorter(access,
                    desc,
                    super.visitMethod(access,
                            name,
                            desc,
                            signature,
                            exceptions));
        }
    }, false);
    byte[] b = cw.toByteArray();
    try {
        LOADER.defineClass(n, b);
    } catch (ClassFormatError cfe) {
        fail(cfe.getMessage());
    } catch (Throwable ignored) {
    }
}
项目:annotation-tools    文件:ASMPerfTest.java   
byte[] nullAdaptClass(final InputStream is, final String name)
        throws Exception
{
    ClassReader cr = new ClassReader(is);
    ClassWriter cw = new ClassWriter(compute);
    ClassAdapter ca = new ClassAdapter(cw);
    cr.accept(ca, skipDebug);
    return cw.toByteArray();
}
项目:annotation-tools    文件:ASMPerfTest.java   
byte[] counterAdaptClass(final InputStream is, final String name)
        throws Exception
{
    ClassReader cr = new ClassReader(is);
    ClassWriter cw = new ClassWriter(false);
    ClassAdapter ca = new CounterClassAdapter(cw);
    cr.accept(ca, false);
    return cw.toByteArray();
}