1 30 package org.objectweb.asm.util.attrs; 31 32 import java.io.InputStream ; 33 import java.io.PrintWriter ; 34 import java.io.StringWriter ; 35 import java.lang.reflect.Method ; 36 37 import org.objectweb.asm.AbstractTest; 38 import org.objectweb.asm.ClassReader; 39 import org.objectweb.asm.attrs.StackMapTableAttributeTest; 40 import org.objectweb.asm.util.ASMifierClassVisitor; 41 import org.objectweb.asm.util.ASMifierTest; 42 import org.objectweb.asm.util.AbstractVisitor; 43 44 49 public class ASMStackMapTableAttributeTest extends AbstractTest { 50 51 public ASMStackMapTableAttributeTest() { 52 super(); 53 } 54 55 public void test() throws Exception { 56 String n = "org.objectweb.asm.attrs.StackMapTableSample"; 57 InputStream is = StackMapTableAttributeTest.class.getResourceAsStream(StackMapTableAttributeTest.TEST_CLASS); 58 ClassReader cr = new ClassReader(is); 59 60 StringWriter sw = new StringWriter (); 61 ASMifierClassVisitor cv = new ASMifierClassVisitor(new PrintWriter (sw)); 62 cr.accept(cv, AbstractVisitor.getDefaultAttributes(), false); 63 64 String generated = sw.toString(); 65 66 byte[] generatorClassData; 67 try { 68 generatorClassData = ASMifierTest.COMPILER.compile(n, generated); 69 System.err.println(generated); 70 } catch (Exception ex) { 71 System.err.println(generated); 72 System.err.println("------------------"); 73 throw ex; 74 } 75 76 Class c = ASMifierTest.LOADER.defineClass("asm." + n + "Dump", 77 generatorClassData); 78 Method m = c.getMethod("dump", new Class [0]); 79 byte[] b = (byte[]) m.invoke(null, new Object [0]); 80 81 assertEquals(cr, new ClassReader(b)); 82 } 83 84 } 85 | Popular Tags |