Search in sources :

Example 1 with ClassPrinter

use of org.springsource.loaded.test.infra.ClassPrinter in project spring-loaded by spring-projects.

the class SpringLoadedTests method printItAndReturnIt.

protected String printItAndReturnIt(byte[] classdata, boolean quoted) {
    OutputStream os = new SimpleOutputStream();
    ClassReader reader = new ClassReader(classdata);
    reader.accept(new ClassPrinter(new PrintStream(os)), 0);
    StringBuffer sb = new StringBuffer(os.toString().replace("\r", ""));
    if (!quoted) {
        return sb.toString();
    }
    for (int i = 0; i < sb.length(); i++) {
        if (sb.charAt(i) == '\n') {
            sb.insert(i + 1, "\"");
            sb.insert(i, "\\n\"+");
            i += 4;
        }
    }
    sb.delete(sb.length() - 3, sb.length());
    sb.insert(0, "\"");
    return sb.toString();
}
Also used : PrintStream(java.io.PrintStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) ClassReader(org.objectweb.asm.ClassReader) ClassPrinter(org.springsource.loaded.test.infra.ClassPrinter)

Example 2 with ClassPrinter

use of org.springsource.loaded.test.infra.ClassPrinter in project spring-loaded by spring-projects.

the class SpringLoadedTests method print.

protected void print(byte[] classdata) {
    ClassReader reader = new ClassReader(classdata);
    reader.accept(new ClassPrinter(System.out), 0);
}
Also used : ClassReader(org.objectweb.asm.ClassReader) ClassPrinter(org.springsource.loaded.test.infra.ClassPrinter)

Aggregations

ClassReader (org.objectweb.asm.ClassReader)2 ClassPrinter (org.springsource.loaded.test.infra.ClassPrinter)2 BufferedOutputStream (java.io.BufferedOutputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 PrintStream (java.io.PrintStream)1