Details
-
Improvement
-
Status: Open
-
Critical
-
Resolution: Unresolved
-
None
-
None
-
None
-
Important
Description
I am trying to add new feature dropToFrame along the lines of suspend.
i.e. in case of suspend, method will return to caller by capturing the state of information. Whereas in dropToFrame I should GOTO startLabel.
So that in some condition I want to re-execute same method(I'll be storing thread state at the beginning, which I restore when I dropToFrame).
I tried to the same by making following code changes.
mv.visitLabel(startLabel); in ContinuationMethodAdapter.visitCode()
Create a variable isDropFrame in StackRecorder.
Added following code in ContinuationMethodAdapter.visitMethodInsn() as below.
Label skipDrop = new Label();
mv.visitVarInsn(ALOAD, stackRecorderVar);
mv.visitJumpInsn(IFNULL, fl);
mv.visitVarInsn(ALOAD, stackRecorderVar);
mv.visitFieldInsn(GETFIELD, STACK_RECORDER, "isDropFrame", "Z");
mv.visitJumpInsn(IFNE, fl);
mv.visitJumpInsn(GOTO, startLabel);
mv.visitLabel(skipDrop);
When I run main method I am getting following exception.
java.lang.ArrayIndexOutOfBoundsException: 0
at org.objectweb.asm.Frame.merge(Frame.java:1380)
at org.objectweb.asm.Frame.merge(Frame.java:1336)
at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1355)
at org.objectweb.asm.MethodVisitor.visitMaxs(MethodVisitor.java:577)
at org.objectweb.asm.util.CheckMethodAdapter.visitMaxs(CheckMethodAdapter.java:865)
at org.apache.commons.javaflow.bytecode.transformation.asm.ContinuationMethodAdapter.visitMaxs(ContinuationMethodAdapter.java:341)
at org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:643)
at org.apache.commons.javaflow.bytecode.transformation.asm.ContinuationMethodAnalyzer.visitEnd(ContinuationMethodAnalyzer.java:146)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:1625)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:533)
Some people told me to use visitFrame() at creation of label or at GOTO statement. I tried both in different combination but still seeing the same exception.
I am struck at this from 5 days.
Could you please tell what exactly I should do to get solution to my problem.(GOTO startlabel in conditions).
Or are there any plans to have this feature in coming releases?