mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Fix bug in decompiling nested catch blocks with complex control flow
This commit is contained in:
parent
7b989a4c1c
commit
c15709994f
|
@ -415,7 +415,7 @@ public class Decompiler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = oldBlock.tryCatches.size() - 1; j >= 0; --j) {
|
for (int j = 0; j < oldBlock.tryCatches.size(); ++j) {
|
||||||
TryCatchBookmark bookmark = oldBlock.tryCatches.get(j);
|
TryCatchBookmark bookmark = oldBlock.tryCatches.get(j);
|
||||||
TryCatchStatement tryCatchStmt = new TryCatchStatement();
|
TryCatchStatement tryCatchStmt = new TryCatchStatement();
|
||||||
tryCatchStmt.setExceptionType(bookmark.exceptionType);
|
tryCatchStmt.setExceptionType(bookmark.exceptionType);
|
||||||
|
@ -428,7 +428,7 @@ public class Decompiler {
|
||||||
if (!tryCatchStmt.getProtectedBody().isEmpty()) {
|
if (!tryCatchStmt.getProtectedBody().isEmpty()) {
|
||||||
blockPart.add(tryCatchStmt);
|
blockPart.add(tryCatchStmt);
|
||||||
}
|
}
|
||||||
inheritedBookmarks.add(bookmark);
|
inheritedBookmarks.add(0, bookmark);
|
||||||
}
|
}
|
||||||
oldBlock.tryCatches.clear();
|
oldBlock.tryCatches.clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,6 +101,24 @@ public class VMTest {
|
||||||
assertEquals("before;inside;after;finally;", sb.toString());
|
assertEquals("before;inside;after;finally;", sb.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void catchFinally() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
try {
|
||||||
|
if (Integer.parseInt("invalid") > 0) {
|
||||||
|
sb.append("err1;");
|
||||||
|
} else {
|
||||||
|
sb.append("err2;");
|
||||||
|
}
|
||||||
|
sb.append("err3");
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
sb.append("catch;");
|
||||||
|
} finally {
|
||||||
|
sb.append("finally;");
|
||||||
|
}
|
||||||
|
assertEquals("catch;finally;", sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void surrogateInStringLiteralsWork() {
|
public void surrogateInStringLiteralsWork() {
|
||||||
assertEquals(0xDDC2, "a\uDDC2b".charAt(1));
|
assertEquals(0xDDC2, "a\uDDC2b".charAt(1));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user