зеркало из https://github.com/mozilla/pluotsorbet.git
Fix exception handling location.
This commit is contained in:
Родитель
7606d03915
Коммит
83618a2cd7
|
@ -53,6 +53,7 @@ module J2ME {
|
|||
stack: any [];
|
||||
code: Uint8Array;
|
||||
pc: number;
|
||||
opPc: number;
|
||||
cp: any;
|
||||
localBase: number;
|
||||
lockObject: java.lang.Object;
|
||||
|
@ -62,6 +63,7 @@ module J2ME {
|
|||
this.cp = methodInfo.classInfo.constant_pool;
|
||||
this.code = methodInfo.code;
|
||||
this.pc = 0;
|
||||
this.opPc = 0;
|
||||
this.stack = [];
|
||||
this.local = local;
|
||||
this.localBase = localBase;
|
||||
|
|
|
@ -172,7 +172,7 @@ module J2ME {
|
|||
var exception_table = frame.methodInfo.exception_table;
|
||||
var handler_pc = null;
|
||||
for (var i=0; exception_table && i<exception_table.length; i++) {
|
||||
if (frame.pc >= exception_table[i].start_pc && frame.pc <= exception_table[i].end_pc) {
|
||||
if (frame.opPc >= exception_table[i].start_pc && frame.opPc < exception_table[i].end_pc) {
|
||||
if (exception_table[i].catch_type === 0) {
|
||||
handler_pc = exception_table[i].handler_pc;
|
||||
break;
|
||||
|
@ -272,7 +272,7 @@ module J2ME {
|
|||
while (true) {
|
||||
ops ++;
|
||||
frame.methodInfo.opCount ++;
|
||||
|
||||
frame.opPc = frame.pc;
|
||||
var op: Bytecodes = frame.read8();
|
||||
if (traceBytecodes) {
|
||||
if (traceSourceLocation) {
|
||||
|
|
|
@ -67,7 +67,7 @@ var gfxTests = [
|
|||
];
|
||||
|
||||
var expectedUnitTestResults = [
|
||||
{ name: "pass", number: 71569 },
|
||||
{ name: "pass", number: 71570 },
|
||||
{ name: "fail", number: 0 },
|
||||
{ name: "known fail", number: 180 },
|
||||
{ name: "unknown pass", number: 0 }
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package java.lang;
|
||||
|
||||
import gnu.testlet.Testlet;
|
||||
import gnu.testlet.TestHarness;
|
||||
|
||||
public class TestExceptionLocation implements Testlet {
|
||||
|
||||
private void foo1() {
|
||||
int a[] = new int[1];
|
||||
// This will trigger an array index exception, that should not be
|
||||
// handled by the following try/catch block.
|
||||
a[10] = 1;
|
||||
try {
|
||||
int i = 0;
|
||||
} catch (Exception e) {
|
||||
// This should not happen
|
||||
}
|
||||
}
|
||||
|
||||
public void test(TestHarness th) {
|
||||
try {
|
||||
foo1();
|
||||
th.fail();
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
th.check(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Загрузка…
Ссылка в новой задаче