return new GASMifierTest().getSuite();
}
@Override
public void test() throws Exception {
ClassReader cr = new ClassReader(is);
if (cr.b.length > 20000) {
return;
}
StringWriter sw = new StringWriter();
GASMifierClassVisitor cv = new GASMifierClassVisitor(new PrintWriter(sw));
cr.accept(cv,
new Attribute[] { new Comment(), new CodeComment() },
ClassReader.EXPAND_FRAMES);
String generated = sw.toString();
byte[] generatorClassData;
try {
generatorClassData = COMPILER.compile(n, generated);
} catch (Exception ex) {
trace(generated);
throw ex;
}
ClassWriter cw = new ClassWriter(0);
cr.accept(new ClassAdapter(cw) {
@Override
public MethodVisitor visitMethod(
final int access,
final String name,
final String desc,
final String signature,
final String[] exceptions)
{
return new LocalVariablesSorter(access,
desc,
super.visitMethod(access,
name,
desc,
signature,
exceptions));
}
},
new Attribute[] { new Comment(), new CodeComment() },
ClassReader.EXPAND_FRAMES);
cr = new ClassReader(cw.toByteArray());
String nd = n + "Dump";
if (n.indexOf('.') != -1) {
nd = "asm." + nd;
}
Class<?> c = LOADER.defineClass(nd, generatorClassData);
Method m = c.getMethod("dump", new Class<?>[0]);
byte[] b;
try {
b = (byte[]) m.invoke(null, new Object[0]);
} catch (InvocationTargetException ex) {
trace(generated);
throw (Exception) ex.getTargetException();
}
try {
assertEquals(cr, new ClassReader(b), new Filter(), new Filter());
} catch (Throwable e) {
trace(generated);
assertEquals(cr, new ClassReader(b), new Filter(), new Filter());
}
}