I am trying to create bytecode that will instantiate an object without code initialization logic. In fact, I want to reproduce the generateSerializationConstructor behavior.
{ mv = cw.visitMethod(ACC_PUBLIC, "newObjectInstance", "()Ljava/lang/Object;", null, null); mv.visitCode(); mv.visitTypeInsn(NEW, classNameInternal); mv.visitInsn(DUP); classNameInternal = "java/lang/Object"; mv.visitMethodInsn(INVOKESPECIAL, classNameInternal, "<init>", "()V"); mv.visitInsn(ARETURN); mv.visitMaxs(0, 0); mv.visitEnd(); }
Unfortunately, I got this error:
java.lang.VerifyError: (class: com / esotericsoftware / reflectasm / benchmark / ConstructorAccessBenchmark $ SomeClass_ClassAccess_, method: newObjectInstance signature :() Ljava / lang / Object;) Calling the wrong initialization method
source share