commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sainath (JIRA)" <>
Subject [jira] [Created] (SANDBOX-500) Need a feature to re-execute same method, i.e. GOTO:<beginning of the method>
Date Tue, 28 Jul 2015 05:45:04 GMT
Sainath created SANDBOX-500:

             Summary: Need a feature to re-execute same method, i.e. GOTO:<beginning of
the method>
                 Key: SANDBOX-500
             Project: Commons Sandbox
          Issue Type: Improvement
          Components: Javaflow
            Reporter: Sainath

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);

When I run main method I am getting following exception.

java.lang.ArrayIndexOutOfBoundsException: 0
	at org.objectweb.asm.Frame.merge(
	at org.objectweb.asm.Frame.merge(
	at org.objectweb.asm.MethodWriter.visitMaxs(
	at org.objectweb.asm.MethodVisitor.visitMaxs(
	at org.objectweb.asm.util.CheckMethodAdapter.visitMaxs(
	at org.apache.commons.javaflow.bytecode.transformation.asm.ContinuationMethodAdapter.visitMaxs(
	at org.objectweb.asm.tree.MethodNode.accept(
	at org.apache.commons.javaflow.bytecode.transformation.asm.ContinuationMethodAnalyzer.visitEnd(
	at org.objectweb.asm.ClassReader.accept(
	at org.objectweb.asm.ClassReader.accept(

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?

This message was sent by Atlassian JIRA

View raw message