Commit 2554c7c6 authored by Remi Forax's avatar Remi Forax

Merge branch 'check-method-adapter-doesn't-allow-<init>-when-ldc-a-method-handle' into 'master'

Check method adapter doesn't allow <init> when ldc a method handle

See merge request !192
parents 24ce41ec d078f4f3
......@@ -1199,7 +1199,10 @@ public class CheckMethodAdapter extends MethodVisitor {
} else {
checkMethodDescriptor(this.version, handle.getDesc());
}
checkMethodIdentifier(this.version, handle.getName(), "handle name");
String handleName = handle.getName();
if (!("<init>".equals(handleName) && tag == Opcodes.H_NEWINVOKESPECIAL)) {
checkMethodIdentifier(this.version, handleName, "handle name");
}
} else if (value instanceof ConstantDynamic) {
if ((version & 0xFFFF) < Opcodes.V11) {
throw new IllegalArgumentException("ldc of a ConstantDynamic requires at least version 11");
......
......@@ -489,6 +489,14 @@ public class CheckMethodAdapterTest extends AsmTest implements Opcodes {
assertThrows(
RuntimeException.class,
() -> checkMethodAdapter.visitLdcInsn(new Handle(-1, "o", "m", "()V", false)));
checkMethodAdapter.visitLdcInsn(
new Handle(Opcodes.H_NEWINVOKESPECIAL, "o", "<init>", "()V", false));
assertThrows(
RuntimeException.class,
() ->
checkMethodAdapter.visitLdcInsn(
new Handle(Opcodes.H_INVOKEVIRTUAL, "o", "<init>", "()V", false)));
}
@Test
......
Markdown is supported
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