Rhino + env.rhino.js StackOverflowError on Android
I've read reports of others successfully using env.rhino.js on Android. I also got a rhino working fine in an Android app and ran simple scripts passing arguments in both directions between Java and JavaScript. However, when I try to use env.rhino.js, no matter which version of envJs I find and use, and no matter which rhinoceros (tried rhino1_7R2, rhino1_7R5 and rhino1_7R5pre) I get a StackOverflowError. The code in the action based class is as follows:
public void envjsTest() {
String envJs = convertAssetToString("env.rhino.js");
Context cx = ContextFactory.getGlobal().enterContext();
cx.setOptimizationLevel(-1);
cx.setLanguageVersion(Context.VERSION_1_8);
try {
Scriptable scope = cx.initStandardObjects();
cx.evaluateString(scope, envJs, "env.rhino.js", 1, null);
} finally {
Context.exit();
}
}
Tried different VERSION settings too, nothing helps. I am getting a stack trace:
01-18 14:27:18.389: ERROR/AndroidRuntime(2447): FATAL EXCEPTION: main
java.lang.StackOverflowError
at org.mozilla.javascript.Decompiler.appendString(Decompiler.java:208)
at org.mozilla.javascript.Decompiler.addName(Decompiler.java:121)
at org.mozilla.javascript.IRFactory.transformName(IRFactory.java:811)
at org.mozilla.javascript.IRFactory.transform(IRFactory.java:120)
at org.mozilla.javascript.IRFactory.transformInfix(IRFactory.java:738)
at org.mozilla.javascript.IRFactory.transform(IRFactory.java:161)
at org.mozilla.javascript.IRFactory.transformInfix(IRFactory.java:738)
at org.mozilla.javascript.IRFactory.transform(IRFactory.java:161)
at org.mozilla.javascript.IRFactory.transformInfix(IRFactory.java:738)
at org.mozilla.javascript.IRFactory.transform(IRFactory.java:161)
at org.mozilla.javascript.IRFactory.transformInfix(IRFactory.java:740)
at org.mozilla.javascript.IRFactory.transform(IRFactory.java:161)
at org.mozilla.javascript.IRFactory.transformInfix(IRFactory.java:740)
at org.mozilla.javascript.IRFactory.transform(IRFactory.java:161)
at org.mozilla.javascript.IRFactory.transformInfix(IRFactory.java:740)
at org.mozilla.javascript.IRFactory.transform(IRFactory.java:161)
at org.mozilla.javascript.IRFactory.transfor ...
How can this be fixed? Again, a similar function executes plain, simple JavaScript code. And please don't tell me to use a WebView to execute JavaScript code instead. I need a JavaScript-powered "mute browser" that can be called from an Android service to do some web scraping in the background while the user is doing something else on the screen.
Greg
source to share
No one has answered this question yet
Check out similar questions: