Commit e142c555 authored by Yudi Zheng's avatar Yudi Zheng
Browse files

BugFixed: Now empty stack is handled correctly.

parent a82cf361
......@@ -242,7 +242,8 @@ public class Weaver {
// exception handler will discard the stack and push the
// exception object. Thus, before entering this snippet,
// weaver must backup the stack and restore when exiting
if (code.containsHandledException()) {
if (code.containsHandledException()
&& info.stackNotEmpty(index)) {
InsnList backup = info.backupStack(index,
methodNode.maxLocals);
......@@ -281,7 +282,8 @@ public class Weaver {
int index = info.getStackEnd().get(exit);
// backup and restore the stack
if (code.containsHandledException()) {
if (code.containsHandledException()
&& info.stackNotEmpty(index)) {
InsnList backup = info.backupStack(index,
methodNode.maxLocals);
......
......@@ -220,6 +220,10 @@ public class WeavingInfo {
return sourceFrameMap.get(instr);
}
public boolean stackNotEmpty(int index) {
return basicFrames[index].getStackSize() > 0;
}
public InsnList backupStack(int index, int startFrom) {
return StackUtil.enter(basicFrames[index], startFrom);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment