I am trying to use the ASM framework to inject bytecode in my place of interest, and I have been successful so far. I am currently trying to enter code that basically creates a new instance / object of the class and after reading the bit I can achieve this using INVOKESPECIAL (I hope that my understanding was correct for INVOKESPECIAL "INVOKESPECIAL" for private methods and constructors) .
Below is the code snippet that I used to create the instance
visitor.visitLdcInsn(System.currentTimeMillis()); visitor.visitLdcInsn(System.currentTimeMillis()); visitor.visitLdcInsn(_type); visitor.visitVarInsn(ALOAD, metanamevarindex); eventObject = newLocal(Type.getType("com/vish/RequestTrackerEvent")); visitor.visitMethodInsn(Opcodes.INVOKESPECIAL, "com/vish/RequestTrackerEvent", "<init>", "(JJLjava/lang/String;Ljava/lang/String;)V"); visitor.visitVarInsn(ASTORE, eventObject);
The class constructor takes 4 arguments (long, long, String, String) But whenever I do this, I get an exception like below
java.lang.VerifyError: JVMVRFY036 stack underflow; at java.lang.J9VMInternals.verifyImpl(Native Method) at java.lang.J9VMInternals.verify(J9VMInternals.java:72) at java.lang.J9VMInternals.verify(J9VMInternals.java:70) at java.lang.J9VMInternals.initialize(J9VMInternals.java:134)
Can someone help me in understanding the correctness of my use / understanding of INVOKESPECIAL, if right, where am I doing wrong?
thanks
source share