我收到此错误:
java.lang.VerifyError: Bad <init> method call in method FooBar.<init>(I)V at offset 2
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2404)
at java.lang.Class.getConstructor0(Class.java:2714)
at java.lang.Class.getDeclaredConstructor(Class.java:2002)
尝试访问我使用 ASM 4.0(使用 jdk7)修改的类的构造函数时。
我检查了类的初始化方法的字节码,如下所示:
aload_0
iload_1
invokespecial com/foo/F/<init>(I)V
return
反编译字节码会产生:
import com.foo.Foo;
public class FooBar extends Foo
{
public FooBar(int i)
{
super(i);
}
}
我完全不知道为什么会收到此错误。我不知道我是否提供了足够的信息;如果我可以添加更多信息,请告诉我。
编辑:这是访问构造函数的代码:
Class fooBarClass = /* define class from class file bytes */;
Constructor fooBarConstructor = fooBarClass.getDeclaredConstructor(int.class);
EDIT2:这是 Foo 类的代码:
public class Foo extends F {
public Foo(int i) {
super(i);
}
}