我正在尝试在Android的Java应用程序中使用Mozilla Rhino来评估一些JavaScript.我正在使用Eclipse + ADT插件.
首先,我尝试从Mozilla的网站下载Rhino .jar文件,并将其作为Eclipse中的库添加到项目中.Eclipse认识到它很好并编译了应用程序.但是,在运行它时,我在调用时会遇到异常Context.evaluateReader()
(请参阅下面的堆栈跟踪).
然后我尝试将Rhino源代码添加为Eclipse中的单独Android项目,将其标记为库并在我的项目中引用它,这足以让Eclipse将其编译,但导致了同样的错误.
这是我得到的堆栈跟踪(java.lang.UnsupportedOperationException: can't load this type of class file
)
Thread [<7> Thread-8] (Suspended (exception UnsupportedOperationException))
DefiningClassLoader(ClassLoader).defineClass(String, byte[], int, int, ProtectionDomain) line: 338
DefiningClassLoader.defineClass(String, byte[]) line: 62
Codegen.defineClass(Object, Object) line: 159
Codegen.createScriptObject(Object, Object) line: 114
Context.compileImpl(Scriptable, Reader, String, String, int, Object, boolean, Evaluator, ErrorReporter) line: 2440
Context.compileReader(Reader, String, int, Object) line: 1326
Context.compileReader(Scriptable, Reader, String, int, Object) line: 1298
Context.evaluateReader(Scriptable, Reader, String, int, Object) line: 1137
TimetableProcessor.evaluate(InputStream, String, String[]) …
Run Code Online (Sandbox Code Playgroud)