下面列出了怎么用org.objectweb.asm.util.ASMifier的API类实例代码及写法,或者点击链接到github查看源代码。
public String dumpASM(byte[] bytecode) {
if (bytecode == null) {
throw new NullPointerException("bytecode");
}
return writeBytecode(bytecode, new ASMifier());
}
public static void dump(Acceptor acceptor, File file, boolean filterImportant, boolean sortLocals, boolean textify) {
try {
if(!file.getParentFile().exists())
file.getParentFile().mkdirs();
if(!file.exists())
file.createNewFile();
PrintWriter pout = new PrintWriter(file);
ClassVisitor cv = new TraceClassVisitor(null, textify ? new Textifier() : new ASMifier(), pout);
if(filterImportant) cv = new ImportantInsnVisitor(cv);
if(sortLocals) cv = new LocalVariablesSorterVisitor(cv);
acceptor.accept(cv);
pout.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public void main (String[] args) throws IOException {
for (String arg: args) {
new ClassReader(OriginalBytecodeGen.class.getResourceAsStream((arg+".class")))
.accept(new TraceClassVisitor(null, new ASMifier(), new PrintWriter(new File((arg+".txt")))), 0);
}
}
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/runtime/callsite/PogoMetaMethodSite.class"});
// ASMifierClassVisitor.main(new String[]{"target/test-classes/spectralnorm.class"});
// ASMifierClassVisitor.main(new String[]{"target/test-classes/groovy/bugs/CustomMetaClassTest.class"});
}
@Test
public void generateASM()
throws Exception
{
ASMifier.main( new String[]{ SomeMixin_Stubx.class.getName() } );
}
protected void printClass(final byte[] bs) {
final ClassReader reader = new ClassReader(bs);
reader.accept(new TraceClassVisitor(null, new ASMifier(), new PrintWriter(
System.out)), ClassReader.EXPAND_FRAMES);
}
protected void printMutant(final Mutant mutant) {
final ClassReader reader = new ClassReader(mutant.getBytes());
reader.accept(new TraceClassVisitor(null, new ASMifier(), new PrintWriter(
System.out)), ClassReader.EXPAND_FRAMES);
}
protected void printClass(final byte[] bs) {
final ClassReader reader = new ClassReader(bs);
reader.accept(new TraceClassVisitor(null, new ASMifier(), new PrintWriter(
System.out)), ClassReader.EXPAND_FRAMES);
}
/**
* @param args
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
ASMifier.main(new String[] { "org.beetl.performance.lab.asm.PrivateTestGet" });
}
/**
* @param args
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
ASMifier.main(new String[] { "com.beetl.performance.lab.asm.field.UserIdFiledAccess" });
}
/**
* @param args
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
ASMifier.main(new String[] { "org.beetl.performance.lab.asm.PrivateTestGet" });
}
/**
* @param args
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
ASMifier.main(new String[] { "com.beetl.performance.lab.asm.field.UserIdFiledAccess" });
}