VM stops if RuntimeException is not handled in a thread.

An error is thrown in context.js:
 TypeError: caller is undefined
This commit is contained in:
Pin Zhang 2014-10-28 19:20:08 +08:00
Родитель 876c4512d6
Коммит 0c3cf74a2e
3 изменённых файлов: 46 добавлений и 2 удалений

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

@ -41,7 +41,7 @@ casper.test.begin("unit tests", 5 + gfxTests.length, function(test) {
.withFrame(0, function() {
casper.waitForText("DONE", function() {
var content = this.getPageContent();
if (content.contains("DONE: 70965 pass, 0 fail, 180 known fail, 0 unknown pass")) {
if (content.contains("DONE: 70966 pass, 0 fail, 180 known fail, 0 unknown pass")) {
test.pass('main unit tests');
} else {
this.debugPage();

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

@ -0,0 +1,28 @@
package java.lang;
import gnu.testlet.Testlet;
import gnu.testlet.TestHarness;
public class TestThread implements Testlet {
private boolean result = false;
class RuntimeExceptionThread extends Thread {
public void run() {
throw new RuntimeException("runtime exception");
}
}
public void test(TestHarness th) {
try {
Thread t = new RuntimeExceptionThread();
t.start();
t.join();
result = true;
} catch (InterruptedException e) {
th.fail("unexpected InterruptedException");
}
th.check(result);
}
}

18
vm.js
Просмотреть файл

@ -103,10 +103,26 @@ VM.execute = function(ctx) {
return;
}
if (ctx.frames.length == 1) {
break;
}
popFrame(0);
} while (frame.methodInfo);
ctx.kill();
throw new Error(buildExceptionLog(ex, stackTrace));
if (ctx.thread && ctx.thread.waiting && ctx.thread.waiting.length > 0) {
console.error(buildExceptionLog(ex, stackTrace));
ctx.thread.waiting.forEach(function(waitingCtx, n) {
ctx.thread.waiting[n] = null;
waitingCtx.wakeup(ctx.thread);
});
} else {
throw new Error(buildExceptionLog(ex, stackTrace));
}
}
function checkArrayAccess(refArray, idx) {