Fix exception handling location.

This commit is contained in:
Brendan Dahl 2015-01-07 15:08:56 -08:00
Родитель 7606d03915
Коммит 83618a2cd7
4 изменённых файлов: 34 добавлений и 3 удалений

Просмотреть файл

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