当前位置: 首页>>代码示例>>Java>>正文


Java ASMifier类代码示例

本文整理汇总了Java中org.objectweb.asm.util.ASMifier的典型用法代码示例。如果您正苦于以下问题:Java ASMifier类的具体用法?Java ASMifier怎么用?Java ASMifier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ASMifier类属于org.objectweb.asm.util包,在下文中一共展示了ASMifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadClass

import org.objectweb.asm.util.ASMifier; //导入依赖的package包/类
private ClassNode loadClass(String name) {
  return Try.apply(() -> {
    String cname = name.replace("/", ".");
    ClassNode node = cache.get(cname);
    if (node == null) {
      String rname = cname.replace(".", "/") + ".class";
      try (InputStream in = loader.getResourceAsStream(rname)) {
        if (in == null) {
          throw new FileNotFoundException(rname + " using " + loader);
        }
        ClassReader reader = new ClassReader(ByteStreams.toByteArray(in));
        node = new ClassNode();
        reader.accept(node, 0);
        cache.put(cname, node);
        if (log.isDebugEnabled()) {
          log.info("Source: {}; Class: {}", node.sourceFile, node.name);
          reader.accept(
              new TraceClassVisitor(null, new ASMifier(), new PrintWriter(writer(log, name))),
              0);
        }
      }
    }
    return node;
  }).get();
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:26,代码来源:BytecodeRouteParser.java

示例2: loadClass

import org.objectweb.asm.util.ASMifier; //导入依赖的package包/类
public Class<?> loadClass(ClassCompilationContext ctx) {
    // generate bytecode
    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
    ctx.getClazz().accept(cw);

    // load class
    Class<?> cls;
    byte[] bb = cw.toByteArray();
    String className = Type.getObjectType(ctx.getClazz().name).getClassName();

    // try {
    // Files.write(bb, new File("target/compiledRecipes/" + ctx.clazz.name
    // + ".class"));
    // } catch (IOException e2) {
    // throw new SaltaException("Error while writing generated class", e2);
    // }

    try {
        cls = getLoader().defineClass(className, bb);
        ctx.initFields(cls);
    } catch (Throwable e) {
        System.out.println("Error while loading compiled recipe class");
        ClassReader cr = new ClassReader(bb);
        cr.accept(new TraceClassVisitor(null, new ASMifier(), new PrintWriter(System.out)), 0);
        CheckClassAdapter.verify(cr, false, new PrintWriter(System.err));

        throw new SaltaException("Error while loading compiled recipe", e);
    }

    // return result
    return cls;
}
 
开发者ID:ruediste,项目名称:salta,代码行数:33,代码来源:RecipeCompiler.java

示例3: newPrinter

import org.objectweb.asm.util.ASMifier; //导入依赖的package包/类
private Printer newPrinter(final String s) {
    Printer printer=new ASMifier(Opcodes.ASM5, "mv", 0) {  // or Textifier(ASM5)
        @Override public void visitMethodEnd() {
            System.out.println("======================== "+s+" ==================");
            PrintWriter p=new PrintWriter(System.out);
            print(p);
            p.flush(); // don't forget that!
        }
    };
    return printer;
}
 
开发者ID:Cojac,项目名称:Cojac,代码行数:12,代码来源:FloatReplaceClassVisitor.java

示例4: main

import org.objectweb.asm.util.ASMifier; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    ImmutableList<Class<?>> classes = ImmutableList.of(
            HelloWorld.class
    );
    for (Class<?> aClass : classes) {
        System.out.println("----------------------------------------------------------------------------------------------------------------------------------");
        ASMifier.main(new String[] {
                aClass.getCanonicalName()
        });
        System.out.println("----------------------------------------------------------------------------------------------------------------------------------");
    }
}
 
开发者ID:pawelprazak,项目名称:jeff,代码行数:13,代码来源:ASMifierTest.java

示例5: printClass

import org.objectweb.asm.util.ASMifier; //导入依赖的package包/类
@Test
public void printClass(){
	try {
		ASMifier.main(new String[]{AccountVO1Wrapper.class.getName()}); 
	} catch (Exception e) {
		Assert.fail("asmifier", e);
	}
}
 
开发者ID:noc0der,项目名称:uranus,代码行数:9,代码来源:GenClassTestCase.java

示例6: gen

import org.objectweb.asm.util.ASMifier; //导入依赖的package包/类
@Test
public void gen(){//得到wrapper的样本
	try {
		ASMifier.main(new String[]{AccountVO.class.getName()});
	} catch (Exception e) {
		Assert.fail("gen class", e);
	}
}
 
开发者ID:noc0der,项目名称:uranus,代码行数:9,代码来源:EntityWrapperTestCase.java

示例7: main

import org.objectweb.asm.util.ASMifier; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
        ASMifier.main(new String[]{"target/classes/groovy/swing/SwingBuilder.class"});
//        ASMifierClassVisitor.main(new String[]{"target/classes/org/codehaus/groovy/tools/shell/util/HelpFormatter.class"});
//        ASMifierClassVisitor.main(new String[]{"target/classes/org/codehaus/groovy/runtime/callsite/PogoMetaMethodSite.class"});
//        ASMifierClassVisitor.main(new String[]{"target/test-classes/spectralnorm.class"});
//        ASMifierClassVisitor.main(new String[]{"target/test-classes/groovy/bugs/CustomMetaClassTest.class"});
    }
 
开发者ID:apache,项目名称:groovy,代码行数:8,代码来源:JO.java

示例8: toASM

import org.objectweb.asm.util.ASMifier; //导入依赖的package包/类
private static String toASM(byte[] transformedBytes) {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    ClassReader cr = new ClassReader(transformedBytes);
    TraceClassVisitor tcv = new TraceClassVisitor(null, new ASMifier(), pw);
    cr.accept(tcv, ClassReader.EXPAND_FRAMES);
    pw.close();
    return sw.toString();
}
 
开发者ID:glowroot,项目名称:glowroot,代码行数:10,代码来源:Weaver.java

示例9: dumpASM

import org.objectweb.asm.util.ASMifier; //导入依赖的package包/类
public String dumpASM(byte[] bytecode) {
    if (bytecode == null) {
        throw new NullPointerException("bytecode must not be null");
    }

    return writeBytecode(bytecode, new ASMifier());
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:8,代码来源:ASMBytecodeDisassembler.java

示例10: visitMethod

import org.objectweb.asm.util.ASMifier; //导入依赖的package包/类
@Override
public ASMifier visitMethod(final int access, final String name,
        final String desc, final String signature, final String[] exceptions) {
    buf.setLength(0);
    buf.append("{\n");
    buf.append("mg = new TestGeneratorAdapter(");
    buf.append(access);
    buf.append(", ");
    buf.append(getMethod(name, desc));
    buf.append(", ");
    if (signature == null) {
        buf.append("null");
    } else {
        buf.append('"').append(signature).append('"');
    }
    buf.append(", ");
    if (exceptions != null && exceptions.length > 0) {
        buf.append("new Type[] {");
        for (int i = 0; i < exceptions.length; ++i) {
            buf.append(i == 0 ? " " : ", ");
            buf.append(getType(exceptions[i]));
        }
        buf.append(" }");
    } else {
        buf.append("null");
    }
    buf.append(", cw);\n");
    text.add(buf.toString());
    GASMifier av = new GASMifier(access, desc);
    text.add(av.getText());
    text.add("}\n");
    return av;
}
 
开发者ID:lrytz,项目名称:asm-legacy-svn-clone,代码行数:34,代码来源:GASMifier.java

示例11: visitLocalVariableAnnotation

import org.objectweb.asm.util.ASMifier; //导入依赖的package包/类
@Override
public Printer visitLocalVariableAnnotation(int typeRef, TypePath typePath,
        Label[] start, Label[] end, int[] index, String desc,
        boolean visible) {
    buf.setLength(0);
    buf.append("{\n").append("av0 = ").append(name)
            .append(".getNext().visitLocalVariableAnnotation(");
    buf.append(typeRef);
    buf.append(", TypePath.fromString(\"").append(typePath).append("\"), ");
    buf.append("new Label[] {");
    for (int i = 0; i < start.length; ++i) {
        buf.append(i == 0 ? " " : ", ");
        appendLabel(start[i]);
    }
    buf.append(" }, new Label[] {");
    for (int i = 0; i < end.length; ++i) {
        buf.append(i == 0 ? " " : ", ");
        appendLabel(end[i]);
    }
    buf.append(" }, new int[] {");
    for (int i = 0; i < index.length; ++i) {
        String idx = index[i] < firstLocal ? new Integer(index[i])
                .toString() : "local" + locals.get(new Integer(index[i]));
        buf.append(i == 0 ? " " : ", ").append(idx);
    }
    buf.append(" }, ");
    appendConstant(desc);
    buf.append(", ").append(visible).append(");\n");
    text.add(buf.toString());
    ASMifier a = createASMifier("av", 0);
    text.add(a.getText());
    text.add("}\n");
    return a;
}
 
开发者ID:lrytz,项目名称:asm-legacy-svn-clone,代码行数:35,代码来源:GASMifier.java

示例12: visitMethod

import org.objectweb.asm.util.ASMifier; //导入依赖的package包/类
@Override
public ASMifier visitMethod(
    final int access,
    final String name,
    final String desc,
    final String signature,
    final String[] exceptions)
{
    buf.setLength(0);
    buf.append("{\n");
    buf.append("mg = new GeneratorAdapter(");
    buf.append(access);
    buf.append(", ");
    buf.append(getMethod(name, desc));
    buf.append(", ");
    if (signature == null) {
        buf.append("null");
    } else {
        buf.append('"').append(signature).append('"');
    }
    buf.append(", ");
    if (exceptions != null && exceptions.length > 0) {
        buf.append("new Type[] {");
        for (int i = 0; i < exceptions.length; ++i) {
            buf.append(i == 0 ? " " : ", ");
            buf.append(getType(exceptions[i]));
        }
        buf.append(" }");
    } else {
        buf.append("null");
    }
    buf.append(", cw);\n");
    text.add(buf.toString());
    GASMifier av = new GASMifier(access, desc);
    text.add(av.getText());
    text.add("}\n");
    return av;
}
 
开发者ID:nxmatic,项目名称:objectweb-asm-4.0,代码行数:39,代码来源:GASMifier.java

示例13: main

import org.objectweb.asm.util.ASMifier; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    ASMifier.main(new String[]{"com.devexperts.dlcheck.tests.base.Test$B"});
}
 
开发者ID:Devexperts,项目名称:dlcheck,代码行数:4,代码来源:TestClass.java

示例14: main

import org.objectweb.asm.util.ASMifier; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
//        Runnable r = new MyClassLoader().load().newInstance();
//        r.run();
        ASMifier.main(new String[]{Test.class.getCanonicalName()});
    }
 
开发者ID:Devexperts,项目名称:dlcheck,代码行数:6,代码来源:Test.java

示例15: main

import org.objectweb.asm.util.ASMifier; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	// "Hi.class" 对应的字节码通过ASM工具怎样一步一步生成出来呢? 通过调用ASMifier.main, 可以得到通过ASM工具生成bytes的详细源码.
	// 解释太绕了, 运行一下便知
	ASMifier.main(new String[]{ "/mywork/myosgi/osgi_workspace/fastquery/target/test-classes/org/fastquery/bean/StudentDBServiceProxyImpl.class"} );
}
 
开发者ID:xixifeng,项目名称:fastquery,代码行数:6,代码来源:TestASMifier.java


注:本文中的org.objectweb.asm.util.ASMifier类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。