Commit 84b03e27 authored by Guillermo Varela's avatar Guillermo Varela
Browse files

Add unit test

parent cc122450
Pipeline #9485 passed with stage
in 6 minutes and 43 seconds
...@@ -636,6 +636,41 @@ public class ClassReaderTest extends AsmTest implements Opcodes { ...@@ -636,6 +636,41 @@ public class ClassReaderTest extends AsmTest implements Opcodes {
assertEquals(Opcodes.V_PREVIEW, classVersion.get() & Opcodes.V_PREVIEW); assertEquals(Opcodes.V_PREVIEW, classVersion.get() & Opcodes.V_PREVIEW);
} }
/** Tests a custom shouldVisitMethodParameters visits MethodParameters even with SKIP_DEBUG. */
@Test
public void testAccept_shouldVisitMethodParameters_Skip_Debug() {
AtomicInteger visitParameterCounter = new AtomicInteger(0);
ClassReader classReader =
new ClassReader(PrecompiledClass.JDK8_LARGE_METHOD.getBytes()) {
@Override
protected boolean shouldVisitMethodParameters(
final int methodParametersOffset, final Context context) {
return true;
}
};
ClassVisitor classVisitor =
new ClassVisitor(/* latest */ Opcodes.ASM10_EXPERIMENTAL) {
@Override
public MethodVisitor visitMethod(
final int access,
final String name,
final String descriptor,
final String signature,
final String[] exceptions) {
return new MethodVisitor(api, null) {
@Override
public void visitParameter(final String name, final int access) {
visitParameterCounter.incrementAndGet();
}
};
}
};
classReader.accept(classVisitor, ClassReader.SKIP_DEBUG);
assertTrue(visitParameterCounter.get() > 0);
}
private static class EmptyClassVisitor extends ClassVisitor { private static class EmptyClassVisitor extends ClassVisitor {
final AnnotationVisitor annotationVisitor = final AnnotationVisitor annotationVisitor =
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment