Cool, thanks for the pointers. I tried posting earlier and it doesn't
appear to have gone through, so please accept my apologies if multiple
similar messages post. :)
I'm experimenting with Rhino and am having more issues. Specifically,
I have this Scala code:
package info.thewordnerd.spiel.utils
import org.mozilla.javascript.Context
import org.mozilla.javascript.Scriptable
object Scripter {
val js = """
"""
def apply() = {
val cx = Context.enter
cx.setOptimizationLevel(-1)
val scope = cx.initStandardObjects
val result = cx.evaluateString(scope, js, "<spiel>", 1, null)
Context.exit
true
}
}
I get this in my logs:
E/AndroidRuntime( 784): Uncaught handler: thread main exiting due to
uncaught exception
E/AndroidRuntime( 784): java.lang.ExceptionInInitializerError
E/AndroidRuntime( 784): at org.mozilla.javascript.Context.enter
(Context.java:411)
E/AndroidRuntime( 784): at org.mozilla.javascript.Context.enter
(Context.java:406)
E/AndroidRuntime( 784): at org.mozilla.javascript.Context.enter
(Context.java:386)
E/AndroidRuntime( 784): at info.thewordnerd.spiel.utils.Scripter
$.apply(Scripter.scala:12)
Looks like the Context.enter call.
Have you encountered this? Is something being caused by the default
optimization level allowing for compilation, perhaps running something
before I can set it to -1?
Or is this another Dalvik issue? :(
Thanks again.
Mark Murphy wrote:
> Nolan Darilek wrote:
> > I'm trying to make my app scriptable. Specifically, I need to expose a
> > few Java APIs and make callbacks settable via user-written scripts.
> > Ideally I'd like to hide some of the complexity away in a DSL, but
> > there's no way of accomplishing what I want neatly without some form
> > of user scripting, so I may accept another alternative if it meets my
> > requirements.
> >
> > Initially I looked into Scala as that is my main language of choice,
> > but the Scala interpreter is just a wrapper around its compiler, which
> > I'm told won't run well if at all on the phone.
> >
> > I've also tried JRuby, which worked under Cupcake. There appears to be
> > a regression in the form of a Dalvik bug that prevents it from working
> > under Donut, however:
> >
> > http://code.google.com/p/android/issues/detail?id=4242
> >
> > Has anyone gotten anything working?
>
> Beanshell works if the intepreter source code is recompiled with a
> modern compiler (the downloads on beanshell.org are built with Java 1.4.2).
>
> Rhino should work if you turn off all optimizations it attempts to do.
> Leastways, I had a version from ~9 months ago working.
>
> I would expect any scripting language that does not generate JVM
> bytecodes to have a decent shot of working on Android, such as Sleep
> (http://sleep.dashnine.org/) and Jacl
> (http://tcljava.sourceforge.net/docs/website/index.html).
>
> > I've also seen the Android Scripting Environment. Am I correct in
> > assuming that this only supports running full interpreters and not
> > embedding scripting languages into apps?
>
> I do not believe ASE is designed with your scenario in mind.
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://twitter.com/commonsguy
>
> Android Training in Germany, 18-22 January 2010: http://bignerdranch.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---