use of org.apache.tapestry5.internal.plastic.asm.util.TraceClassVisitor in project tapestry-5 by apache.
the class PlasticInternalUtils method dissasembleBytecode.
public static String dissasembleBytecode(ClassNode classNode) {
StringWriter stringWriter = new StringWriter();
PrintWriter writer = new PrintWriter(stringWriter);
TraceClassVisitor visitor = new TraceClassVisitor(writer);
classNode.accept(visitor);
writer.close();
return stringWriter.toString();
}
use of org.apache.tapestry5.internal.plastic.asm.util.TraceClassVisitor in project tapestry-5 by apache.
the class Printer method main.
/**
* Prints a the given class to the given output.
*
* <p>Command line arguments: [-nodebug] <binary class name or class file name >
*
* @param args the command line arguments.
* @param usage the help message to show when command line arguments are incorrect.
* @param printer the printer to convert the class into text.
* @param output where to print the result.
* @param logger where to log errors.
* @throws IOException if the class cannot be found, or if an IOException occurs.
*/
static void main(final String[] args, final String usage, final Printer printer, final PrintWriter output, final PrintWriter logger) throws IOException {
if (args.length < 1 || args.length > 2 || ((args[0].equals("-debug") || args[0].equals("-nodebug")) && args.length != 2)) {
logger.println(usage);
return;
}
TraceClassVisitor traceClassVisitor = new TraceClassVisitor(null, printer, output);
String className;
int parsingOptions;
if (args[0].equals("-nodebug")) {
className = args[1];
parsingOptions = ClassReader.SKIP_DEBUG;
} else {
className = args[0];
parsingOptions = 0;
}
if (className.endsWith(".class") || className.indexOf('\\') != -1 || className.indexOf('/') != -1) {
// Can't fix PMD warning for 1.5 compatibility.
try (InputStream inputStream = new FileInputStream(className)) {
// NOPMD(AvoidFileStream)
new ClassReader(inputStream).accept(traceClassVisitor, parsingOptions);
}
} else {
new ClassReader(className).accept(traceClassVisitor, parsingOptions);
}
}
Aggregations