1 30 package org.objectweb.asm.commons; 31 32 import junit.framework.TestSuite; 33 34 import org.objectweb.asm.AbstractTest; 35 import org.objectweb.asm.ClassAdapter; 36 import org.objectweb.asm.ClassReader; 37 import org.objectweb.asm.ClassWriter; 38 import org.objectweb.asm.MethodVisitor; 39 40 45 public class JSRInlinerAdapterTest extends AbstractTest { 46 47 private final static TestClassLoader LOADER = new TestClassLoader(); 48 49 public static TestSuite suite() throws Exception { 50 return new JSRInlinerAdapterTest().getSuite(); 51 } 52 53 public void test() throws Exception { 54 ClassReader cr = new ClassReader(is); 55 ClassWriter cw = new ClassWriter(0); 56 cr.accept(new ClassAdapter(cw) { 57 public MethodVisitor visitMethod( 58 final int access, 59 final String name, 60 final String desc, 61 final String signature, 62 final String [] exceptions) 63 { 64 MethodVisitor mv = super.visitMethod(access, 65 name, 66 desc, 67 signature, 68 exceptions); 69 return new JSRInlinerAdapter(mv, 70 access, 71 name, 72 desc, 73 signature, 74 exceptions); 75 } 76 }, 0); 77 byte[] b = cw.toByteArray(); 78 try { 79 LOADER.defineClass(n, b); 80 } catch (ClassFormatError cfe) { 81 fail(cfe.getMessage()); 82 } catch (Throwable ignored) { 83 } 84 } 85 86 88 static class TestClassLoader extends ClassLoader { 89 90 public Class defineClass(final String name, final byte[] b) { 91 return defineClass(name, b, 0, b.length); 92 } 93 } 94 } 95 | Popular Tags |