});
runTest("deserialize", "tree package", new RunTest() {
@Override
public void test(byte[] bytes, int[] errors) {
new ClassReader(bytes).accept(new ClassNode(), 0);
}
});
System.out.println();
// deserialize and reserialize tests
runTestAll("deserialize and reserialize", "", new RunTest() {
@Override
public void test(byte[] bytes, int[] errors) {
ClassReader cr = new ClassReader(bytes);
ClassWriter cw = new ClassWriter(0);
cr.accept(cw, 0);
cw.toByteArray();
}
});
runTestAll("deserialize and reserialize",
"copyPool",
new RunTest() {
@Override
public void test(byte[] bytes, int[] errors) {
ClassReader cr = new ClassReader(bytes);
ClassWriter cw = new ClassWriter(cr, 0);
cr.accept(cw, 0);
cw.toByteArray();
}
});
runTest("deserialize and reserialize",
"tree package",
new RunTest() {
@Override
public void test(byte[] bytes, int[] errors) {
ClassWriter cw = new ClassWriter(0);
ClassNode cn = new ClassNode();
new ClassReader(bytes).accept(cn, 0);
cn.accept(cw);
cw.toByteArray();
}
});
compute = false;
computeFrames = false;
runTest("deserialize and reserialize", "BCEL", nullBCELAdapt);
runTest("deserialize and reserialize",
"Aspectj BCEL",
nullAspectjBCELAdapt);
runTest("deserialize and reserialize",
"Javassist",
nullJavassistAdapt);
runTest("deserialize and reserialize",
"SERP",
nullSERPAdapt);
System.out.println();
// deserialize and reserialize tests with computeMaxs
runTest("deserialize and reserialize",
"computeMaxs",
new RunTest() {
@Override
public void test(byte[] bytes, int[] errors) {
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
new ClassReader(bytes).accept(cw, 0);
cw.toByteArray();
}
});
compute = true;
computeFrames = false;
runTest("deserialize and reserialize",
"BCEL and computeMaxs",
nullBCELAdapt);
runTest("deserialize and reserialize",
"Aspectj BCEL and computeMaxs",
nullAspectjBCELAdapt);
// misc. tests
runTest("deserialize and reserialize",
"LocalVariablesSorter",
new RunTest() {
@Override
public void test(byte[] bytes, int[] errors) {
ClassWriter cw = new ClassWriter(0);
new ClassReader(bytes).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,
cv.visitMethod(access,
name,
desc,
signature,
exceptions));
}
}, ClassReader.EXPAND_FRAMES);
cw.toByteArray();
}
});
// This test repeatedly tests the same classes as SimpleVerifier
// actually calls Class.forName() on the class which fills the PermGen
runTestSome("analyze", "SimpleVerifier", new RunTest() {
@Override
public void test(byte[] bytes, int[] errors) {
ClassReader cr = new ClassReader(bytes);
ClassNode cn = new ClassNode();
cr.accept(cn, ClassReader.SKIP_DEBUG);
List<MethodNode> methods = cn.methods;
for (int k = 0; k < methods.size(); ++k) {
MethodNode method = methods.get(k);
Analyzer<?> a = new Analyzer<BasicValue>(new SimpleVerifier());