Try walking through VMBridge.makeInstance() in a debugger. The problem might be an inability to map Dalvik to one of the known JDK VMBridges. HTH -Simon
"Nolan Darilek" <[email protected]> wrote in message news:mailman.5459.1255642648.4294.dev-tech-js-engine-rh...@lists.mozilla.org... > OK, I promise not to spam folks with daily updates on this, and this will > be my last message on the topic not in response to something else, but I'm > still at a loss with this and would very much appreciate some help. > > Ultimately, the problem seems to boil down to Context.java:411, which > reads: > > Object helper = VMBridge.instance.getThreadContextHelper(); > > I've scoured the shell example, trying to figure out what it does > differently from the very simple Context.enter() case, and while it goes > about things more circuitously, my attempts to do things similarly always > hit Context.java:411. It's starting to make me think that, while I do > ultimately have to disable optimization, my initial impression was off. I > think this because I've tried adding debugging log statements to my > factory's makeContext, and have even tried to insert a ContextAction via > contextFactory.call(). But none of this ever triggers. > > In short, if I call Context.enter(), or contextFactory.call(), I get the > error detailed below, and none of my attempts to get *anything* running > before this error throws seem to work. I'm not clever enough to delve into > the Dalvik internals, so I've hit my limit as far as knowing what to try. > > Any thoughts? > > On 10/14/2009 08:10 PM, Nolan Darilek wrote: >> Hi, all, hoping someone can give me a few pointers as to what I'm doing >> wrong. >> >> I'm trying to embed Rhino in my Android app to add scripting >> functionality. According to Google, the Rhino shell works fine on >> Android, which I've confirmed by building and running it from source >> under Donut. So unless I'm comparing apples and orangutangs, my use case >> should work too. >> >> First I tried the basic embedding examples from the documentation, though >> I called cx.setOptimization(-1) to disable all compilation. No luck. I >> then thought that perhaps something was being optimized in the context >> before I could turn off optimization, so I created my own ContextFactory, >> and set the optimization level in the onContextCreated() method, but no >> luck. Here's my current Scala code for creating an interpreter and >> evaling an empty string for now: >> >> package info.thewordnerd.spiel.scripting >> >> import org.mozilla.javascript.Context >> import org.mozilla.javascript.ContextFactory >> import org.mozilla.javascript.Scriptable >> >> class MyContextFactory extends ContextFactory { >> override protected def onContextCreated(cx:Context) { >> cx.setOptimizationLevel(-1) >> } >> } >> >> object Scripter { >> >> val js = """ >> """ >> >> def apply() = { >> ContextFactory.initGlobal(new MyContextFactory) >> val cx = Context.enter >> cx.setOptimizationLevel(-1) >> val scope = cx.initStandardObjects >> val result = cx.evaluateString(scope, js, "<spiel>", 1, null) >> Context.exit >> true >> } >> } >> >> Running this on the emulator gives the following error (line 20 in >> scripts.scala is the Context.enter call): >> >> E/AndroidRuntime( 771): Uncaught handler: thread main exiting due to >> uncaught exception >> E/AndroidRuntime( 771): java.lang.ExceptionInInitializerError >> E/AndroidRuntime( 771): at >> org.mozilla.javascript.Context.enter(Context.java:411) >> E/AndroidRuntime( 771): at >> org.mozilla.javascript.Context.enter(Context.java:406) >> E/AndroidRuntime( 771): at >> org.mozilla.javascript.Context.enter(Context.java:386) >> E/AndroidRuntime( 771): at >> info.thewordnerd.spiel.scripting.Scripter$.apply(scripting.scala:20) >> E/AndroidRuntime( 771): at >> info.thewordnerd.spiel.services.Spiel.onServiceConnected(Spiel.scala:28) >> E/AndroidRuntime( 771): at >> android.accessibilityservice.AccessibilityService$IEventListenerWrapper.executeMessage(AccessibilityService.java:222) >> E/AndroidRuntime( 771): at >> com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:45) >> E/AndroidRuntime( 771): at >> android.os.Handler.dispatchMessage(Handler.java:99) >> E/AndroidRuntime( 771): at android.os.Looper.loop(Looper.java:123) >> E/AndroidRuntime( 771): at >> android.app.ActivityThread.main(ActivityThread.java:4203) >> E/AndroidRuntime( 771): at >> java.lang.reflect.Method.invokeNative(Native Method) >> E/AndroidRuntime( 771): at >> java.lang.reflect.Method.invoke(Method.java:521) >> E/AndroidRuntime( 771): at >> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791) >> E/AndroidRuntime( 771): at >> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549) >> E/AndroidRuntime( 771): at dalvik.system.NativeStart.main(Native >> Method) >> E/AndroidRuntime( 771): Caused by: java.lang.IllegalStateException: >> Failed to create VMBridge instance >> E/AndroidRuntime( 771): at >> org.mozilla.javascript.VMBridge.makeInstance(VMBridge.java:69) >> E/AndroidRuntime( 771): at >> org.mozilla.javascript.VMBridge.<clinit>(VMBridge.java:49) >> E/AndroidRuntime( 771): ... 15 more >> >> So what am I missing that lets the shell, compiled on a very similar >> toolchain, work just fine? Is there some setup step I'm missing? >> >> Thanks. >> > _______________________________________________ dev-tech-js-engine-rhino mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
