0
我为我的Java应用程序使用Mozilla Rhino(JavaScript引擎)。我定义是ScriptableObject这样的:Mozilla Rhino - 带自定义对象的ScriptableObject?
public class TheObj extends ScriptableObject {
public TheObj(){
//nothing
}
public TheObj(Scriptable scope, Scriptable prototype) {
super(scope, prototype);
}
@Override
public String getClassName() {
return "Foo";
}
@JSStaticFunction
public static Foo foo(Foo foo){
return foo;
}
}
而Foo类是:
public class Foo {
public void bar(){
System.out.println("it works");
}
}
但是当我尝试ScriptableObject.defineClass(scope, TheObj.class);
其中scope
是Context.enter().initStandardObjects();
编写脚本,然后它抛出
org.mozilla.javascript.EvaluatorException: Unsupported parameter type "Foo" in method "bar".
什么我能解决这个问题吗?