Java用Rhino调用JS(未定义Uint8Array) [英] Java calling JS with Rhino (Uint8Array is not defined)
问题描述
我正在尝试使用Rhino库从Java代码中调用一些JavaScript。但是似乎它在类型数组上令人窒息。这是我的简单js文件
I'm trying to use the Rhino lib to call some javascript from java code. But it seems that it is choking on a typed array. Here is my simple js file
function decrypt(version, iv, encryptedBuffer) {
var output8;
output8 = new Uint8Array(encryptedBuffer);
var outputBuffer = output8.buffer;
var output32 = new Int32Array(outputBuffer);
... more funny code
}
但是在呼叫
But when calling
jsFunction.call(rhino, scope, scope, params);
我明白了这个
sun.org.mozilla.javascript.internal.EcmaError:ReferenceError:
未定义 Uint8Array。 (JavaScript#5680)
sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "Uint8Array" is not defined. (JavaScript#5680)
是否还有其他配置需要运行我的小js代码段?
Is there something extra to configure to have my little js snippet run ?
推荐答案
是否设置了setLanguageVersion(Context.VERSION_ES6)?
Typed Array是新的Javascript功能。
Rhino在旧的js版本中不允许类型化数组调用。
Have you set setLanguageVersion(Context.VERSION_ES6)? Typed Array is new Javascript feature. Rhino does not allow Typed array call in old js versions.
这篇关于Java用Rhino调用JS(未定义Uint8Array)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!