1 30 package org.objectweb.asm; 31 32 import junit.framework.TestSuite; 33 34 39 public class ClassWriterCopyPoolTest extends AbstractTest { 40 41 public static TestSuite suite() throws Exception { 42 return new ClassWriterCopyPoolTest().getSuite(); 43 } 44 45 public void test() throws Exception { 46 ClassReader cr = new ClassReader(is); 47 ClassWriter cw1 = new ClassWriter(0); 48 ClassWriter cw2 = new ClassWriter(cr, 0); 49 cr.accept(new ChangeExceptionAdapter(cw1), 0); 50 cr.accept(new ChangeExceptionAdapter(cw2), 0); 51 assertEquals(new ClassReader(cw1.toByteArray()), 52 new ClassReader(cw2.toByteArray())); 53 } 54 55 static class ChangeExceptionAdapter extends ClassAdapter { 56 57 public ChangeExceptionAdapter(final ClassVisitor cv) { 58 super(cv); 59 } 60 61 public MethodVisitor visitMethod( 62 final int access, 63 final String name, 64 final String desc, 65 final String signature, 66 final String [] exceptions) 67 { 68 if (exceptions != null && exceptions.length > 0) { 69 exceptions[0] = "java/lang/Throwable"; 70 } 71 return super.visitMethod(access, name, desc, signature, exceptions); 72 } 73 } 74 } 75 | Popular Tags |