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 43 public class LocalVariablesSorterTest extends AbstractTest { 44 45 private final static TestClassLoader LOADER = new TestClassLoader(); 46 47 public static TestSuite suite() throws Exception { 48 return new LocalVariablesSorterTest().getSuite(); 49 } 50 51 public void test() throws Exception { 52 ClassReader cr = new ClassReader(is); 53 ClassWriter cw = new ClassWriter(true, true); 54 cr.accept(new ClassAdapter(cw) { 55 public MethodVisitor visitMethod( 56 int access, 57 String name, 58 String desc, 59 String signature, 60 String [] exceptions) 61 { 62 return new LocalVariablesSorter(access, 63 desc, 64 super.visitMethod(access, 65 name, 66 desc, 67 signature, 68 exceptions)); 69 } 70 }, false); 71 byte[] b = cw.toByteArray(); 72 try { 73 LOADER.defineClass(n, b); 74 } catch (ClassFormatError cfe) { 75 fail(cfe.getMessage()); 76 } catch (Throwable ignored) { 77 } 78 } 79 80 82 static class TestClassLoader extends ClassLoader { 83 84 public Class defineClass(final String name, final byte[] b) { 85 return defineClass(name, b, 0, b.length); 86 } 87 } 88 } | Popular Tags |