Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#1 Operand Stack View: EmptyStackException

BCV 4.2.1
closed
2013-05-23
2013-04-05
Sergej Alekseev
No

The following byte code causes an EmptyStackException in the OperandStackView:

void test(int b, int arg1) {
        /* L7 */
        0 nop;
        1 iload_2;                /* b */
        2 if_icmple 7;
        5 iload_1;                /* a */
        6 goto 4;
        9 iload_2;                /* b */
        10 iconst_2;
        11 invokestatic 16;       /* void test.C4.diff(int b, int arg1) */
        /* L8 */
        14 return;
}

The OperandStackView doesn't display any content. An error has to be displayed instead in the View.

java.util.EmptyStackException
    at java.util.Stack.peek(Stack.java:85)
    at java.util.Stack.pop(Stack.java:67)
    at com.drgarbage.bytecodevisualizer.operandstack.OperandStack.processInstruction(OperandStack.java:715)
    at com.drgarbage.bytecodevisualizer.operandstack.OperandStack.calculateOperandStack(OperandStack.java:226)
    at com.drgarbage.bytecodevisualizer.operandstack.OperandStack.parseGraph(OperandStack.java:170)
    at com.drgarbage.bytecodevisualizer.operandstack.OperandStack.generateOperandStack(OperandStack.java:105)
    at com.drgarbage.bytecodevisualizer.operandstack.OperandStack.<init>(OperandStack.java:89)
    at com.drgarbage.bytecodevisualizer.view.OperandStackViewPage.setInput(OperandStackViewPage.java:652)
    at com.drgarbage.bytecodevisualizer.view.OperandStackViewPage.setInput(OperandStackViewPage.java:294)
    at com.drgarbage.bytecodevisualizer.editors.BytecodeEditor.doHandleCursorPositionChanged(BytecodeEditor.java:1312)
    at com.drgarbage.bytecodevisualizer.editors.BytecodeEditor.handleCursorPositionChanged(BytecodeEditor.java:1779)
    at org.eclipse.ui.texteditor.AbstractTextEditor$16.selectionChanged(AbstractTextEditor.java:3143)
    at org.eclipse.jface.viewers.Viewer$2.run(Viewer.java:164)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
    at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)

Discussion

    • status: open --> accepted

    Empty Stack Exception is thrown only if the byte code is inconsistent. For example, when an instruction pops a value from an empty stack.
    The verification algorithm has to be adapted.

     
    Last edit: Sergej Alekseev 2013-05-23
    • status: accepted --> closed
      Error handling has been implemented. Revision 170
     
    Last edit: Sergej Alekseev 2013-05-23