use of jdk.internal.org.objectweb.asm.ClassReader in project jdk8u_jdk by JetBrains.
the class Textifier method main.
/**
* Prints a disassembled view of the given class to the standard output.
* <p>
* Usage: Textifier [-debug] <binary class name or class file name >
*
* @param args
* the command line arguments.
*
* @throws Exception
* if the class cannot be found, or if an IO exception occurs.
*/
public static void main(final String[] args) throws Exception {
int i = 0;
int flags = ClassReader.SKIP_DEBUG;
boolean ok = true;
if (args.length < 1 || args.length > 2) {
ok = false;
}
if (ok && "-debug".equals(args[0])) {
i = 1;
flags = 0;
if (args.length != 2) {
ok = false;
}
}
if (!ok) {
System.err.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);
}
use of jdk.internal.org.objectweb.asm.ClassReader in project warn-report by saaavsaaa.
the class AddFieldAdapter method main.
public static void main(String[] args) throws ClassNotFoundException, IOException, IllegalAccessException, InstantiationException, NoSuchFieldException {
ClassVisitorTest.changeVersion();
byte[] data = ResourceUtil.loadFile("ClassCode.class");
ClassReader cr = new ClassReader(data);
ClassWriter cw = new ClassWriter(0);
// cw = deleteField(cr, cw);
cw = addField(cr, cw);
cw = ClassMethodVisitor.add(cr, cw);
byte[] b = cw.toByteArray();
ResourceUtil.write("ClassCode.class", b);
}
use of jdk.internal.org.objectweb.asm.ClassReader in project warn-report by saaavsaaa.
the class VisitUtil method display.
public static void display(byte[] data) {
ClassReader reader = new ClassReader(data);
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
CheckClassAdapter.verify(reader, true, pw);
System.out.println(sw.toString());
}
use of jdk.internal.org.objectweb.asm.ClassReader in project warn-report by saaavsaaa.
the class DelegageClassAdapter method main.
public static void main(String[] args) throws IOException {
ClassNode cn = new ClassNode(ASM5);
ClassReader cr = new ClassReader("...");
cr.accept(cn, 0);
// 可以在这里根据需要转换 cn
ClassWriter cw = new ClassWriter(0);
cn.accept(cw);
byte[] b = cw.toByteArray();
}
use of jdk.internal.org.objectweb.asm.ClassReader in project jdk8u_jdk by JetBrains.
the class ASMifier method main.
/**
* Prints the ASM source code to generate the given class to the standard
* output.
* <p>
* Usage: ASMifier [-debug] <binary class name or class file name>
*
* @param args
* the command line arguments.
*
* @throws Exception
* if the class cannot be found, or if an IO exception occurs.
*/
public static void main(final String[] args) throws Exception {
int i = 0;
int flags = ClassReader.SKIP_DEBUG;
boolean ok = true;
if (args.length < 1 || args.length > 2) {
ok = false;
}
if (ok && "-debug".equals(args[0])) {
i = 1;
flags = 0;
if (args.length != 2) {
ok = false;
}
}
if (!ok) {
System.err.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);
}
Aggregations