Java asm方法错误
我正在尝试添加一个参数中包含inetaddress的方法,该参数将调用 另一个类中的静态方法具有相同的参数,但是我的代码将抛出verifyerrorJava asm方法错误,java,java-bytecode-asm,Java,Java Bytecode Asm,我正在尝试添加一个参数中包含inetaddress的方法,该参数将调用 另一个类中的静态方法具有相同的参数,但是我的代码将抛出verifyerror MethodNode mv = new MethodNode(ACC_PUBLIC, "startPrivate", "(Ljava/net/InetAddress;)V", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitMethodI
MethodNode mv = new MethodNode(ACC_PUBLIC, "startPrivate", "(Ljava/net/InetAddress;)V", null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESTATIC, "I/Z", "I", "(Ljava/net/InetAddress;)V");
mv.visitInsn(RETURN);
mv.visitMaxs(1, 1);
mv.visitEnd();
into.methods.add(mv);
错误:
Exception in thread "main" java.lang.VerifyError: (class: client, method: startPrivate signature: (Ljava/net/InetAddress;)V) Incompatible argument to function
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2483)
at java.lang.Class.getConstructor0(Class.java:2793)
at java.lang.Class.newInstance(Class.java:345)
at vanquish.Loader.initializeClient(Loader.java:33)
at vanquish.Loader.main(Loader.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
感谢您现在帮助我们工作:
因为您没有指定
ACC\u STATIC
,所以您创建了一个实例方法。因此,变量0中有这个
,因此局部变量的最大数量是错误的,将变量0的内容传递给静态目标方法也是错误的。VerifierError
没有给你一个具体的消息吗
目标方法是否真的被称为I
,并在类I.Z
中声明
MethodNode mv = new MethodNode(ACC_PUBLIC, "startPrivate", "(Ljava/net/InetAddress;)V", null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKESTATIC, "I/Z", "I", "(Ljava/net/InetAddress;)V");
mv.visitInsn(RETURN);
mv.visitMaxs(1, 2);
mv.visitEnd();
into.methods.add(mv);