andreasgal/j2me.js — pull request #60 by mykmelez (2014-08-07 21:30:34+00:00)
Title: set status to STARTED after invoking isolate's main class

This sets status = STARTED after nativeStart invokes the isolate's main class.

That means the status will be STARTED when the test calls waitForExit, so I had to fix a bug in waitForExit, which was relying on waitStatus to wait until the status is >= STOPPED (i.e. the behavior implemented by the native implementation, which is different from the behavior described in the Java class).

Also, calling updateStatus to update the status to STARTED may call a callback that re-calls Runtime.prototype.waitStatus, which then throws VM.Pause, which we don't want to happen in nativeStart. So I trap and discard the exception.

(Although it seems to me like it would be better to throw VM.Pause only in the initial call to the waitStatus native, which is what my earlier implementation did, rather than every time the callback is called.)