зеркало из https://github.com/mozilla/pluotsorbet.git
Merge branch 'master' of https://github.com/andreasgal/j2me.js into jitjit
Conflicts: vm.js
This commit is contained in:
Коммит
318f8bd0c9
66
README.md
66
README.md
|
@ -2,9 +2,67 @@
|
|||
|
||||
j2me.js is a J2ME virtual machine in JavaScript.
|
||||
|
||||
A few similar projects exist. The primary objective here is to keep this very simple and small and to leverage the phoneME JDK. In particular we are trying to implement as little as possible in JavaScript, re-using as much of the phoneME infrastructure and existing Java code as we can.
|
||||
The current goals of j2me.js are:
|
||||
|
||||
#### Run j2me.js in the SpiderMonkey shell
|
||||
1. Run MIDlets in a way that emulates the reference implementation of phone ME Feature MR4 (b01)
|
||||
1. Keep j2me.js simple and small: Leverage the phoneME JDK/infrastructre and existing Java code as much as we can, and implement as little as possible in JavaScript
|
||||
|
||||
1. Download the SpiderMonkey shell (https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Introduction_to_the_JavaScript_shell)
|
||||
2. Execute the jsshell.js file as follows: *js jsshell.js package.ClassName*
|
||||
## Building j2me.js
|
||||
|
||||
Make sure you have a [JRE](http://www.oracle.com/technetwork/java/javase/downloads/jre7-downloads-1880261.html) installed
|
||||
|
||||
Get the [j2me.js repo](https://github.com/andreasgal/j2me.js) if you don't have it already
|
||||
|
||||
git clone https://github.com/andreasgal/j2me.js
|
||||
|
||||
Build using make:
|
||||
|
||||
cd j2me.js
|
||||
make
|
||||
|
||||
## Running MIDlets, tests
|
||||
|
||||
To run a MIDlet:
|
||||
|
||||
python -m SimpleHTTPServer&
|
||||
http://localhost:8000/index.html?jad=ExampleApp.jad&jars=ExampleApp.jar&midletClassName=com.example.yourClassNameHere
|
||||
|
||||
URL parameters:
|
||||
|
||||
* See full list at libs/urlparams.js
|
||||
* Default `midletClassName` if none specified is `RunTests`
|
||||
|
||||
If testing sockets, 4 servers are necessary:
|
||||
|
||||
python -m SimpleHTTPServer &
|
||||
python tests/echoServer.py &
|
||||
cd tests && python httpsServer.py &
|
||||
cd tests && python sslEchoServer.py &
|
||||
|
||||
To run specific tests (e.g. TestSystem and TestRC4):
|
||||
|
||||
python -m SimpleHTTPServer&
|
||||
http://localhost:8000/index.html?args=java/lang/TestSystem,javax/crypto/TestRC4
|
||||
|
||||
Full list of RunTests tests available in the tests/Testlets.java generated file
|
||||
|
||||
There's no UI to enable certain privileges on Desktop that MIDlets might need. Use [Myk's tcpsocketpup addon](https://github.com/mykmelez/tcpsocketpup) to accomplish that
|
||||
|
||||
Continuous integration:
|
||||
|
||||
* Uses Travis
|
||||
* Runs automation.js which uses Casper.js testing framework and slimer.js (Gecko backend for casper.js)
|
||||
* `make test`
|
||||
|
||||
gfx tests use image comparison; output should match reference
|
||||
|
||||
## Logging
|
||||
|
||||
See `logConsole` and `logLevel` URL params in libs/console.js
|
||||
|
||||
## Running j2me.js in the SpiderMonkey shell
|
||||
|
||||
1. Download the [SpiderMonkey shell](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Introduction_to_the_JavaScript_shell)
|
||||
1. Execute the jsshell.js file as follows:
|
||||
|
||||
js jsshell.js package.ClassName
|
||||
|
|
|
@ -14,13 +14,11 @@ var Instrument = {
|
|||
enabled: "instrument" in urlParams && !/no|0/.test(urlParams.instrument),
|
||||
|
||||
callEnterHooks: function(methodInfo, caller, callee) {
|
||||
if (!this.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
var key = methodInfo.implKey;
|
||||
if (Instrument.enter[key]) {
|
||||
Instrument.enter[key](caller, callee);
|
||||
if (this.enabled) {
|
||||
var key = methodInfo.implKey;
|
||||
if (Instrument.enter[key]) {
|
||||
Instrument.enter[key](caller, callee);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.profiling) {
|
||||
|
@ -39,10 +37,6 @@ var Instrument = {
|
|||
},
|
||||
|
||||
callExitHooks: function(methodInfo, caller, callee) {
|
||||
if (!this.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
var key = methodInfo.implKey;
|
||||
|
||||
if (this.profiling) {
|
||||
|
@ -64,8 +58,10 @@ var Instrument = {
|
|||
}
|
||||
}
|
||||
|
||||
if (Instrument.exit[key]) {
|
||||
Instrument.exit[key](caller, callee);
|
||||
if (this.enabled) {
|
||||
if (Instrument.exit[key]) {
|
||||
Instrument.exit[key](caller, callee);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -89,6 +85,11 @@ var Instrument = {
|
|||
|
||||
exitAsyncNative: function(key) {
|
||||
var profileData = this.asyncProfile[key];
|
||||
if (!profileData) {
|
||||
// Ignore native without profile data, which can happen when you start
|
||||
// profiling while the native is pending.
|
||||
return;
|
||||
}
|
||||
profileData.count++;
|
||||
profileData.cost += performance.now() - profileData.then;
|
||||
},
|
||||
|
|
|
@ -39,7 +39,7 @@ casper.test.begin("unit tests", 6 + gfxTests.length, function(test) {
|
|||
function basicUnitTests() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
19
vm.js
19
vm.js
|
@ -166,12 +166,29 @@ function throw_(ex, ctx) {
|
|||
return frame;
|
||||
}
|
||||
|
||||
if (ctx.frames.length == 1) {
|
||||
break;
|
||||
}
|
||||
|
||||
frame = popFrame(ctx, frame, 0);
|
||||
stack = frame.stack;
|
||||
cp = frame.cp;
|
||||
} 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);
|
||||
});
|
||||
|
||||
return frame;
|
||||
} else {
|
||||
throw new Error(buildExceptionLog(ex, stackTrace));
|
||||
}
|
||||
}
|
||||
|
||||
VM.execute = function(ctx) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче