如何在 jsni 方法中使用 int 值?
public class Person extends JavaScriptObject{
// some other methods
public final native void setPoints(int i)/*-{
this.points= this.points + i;
}-*/;
public final native int getPoints()/*-{
return this.points;
}-*/;
}
我在结合 JsArray 的方法中使用它
public static boolean moreThanZeroPoints(JsArray<Person> arr, int index){
if(arr.get(index).getPoints() > 0){
return true;
}
return false;
}
Inarr.get(index).getPoints()
给出以下错误消息:
uncaught: Exception caught: Exception: caught: something other than an int was returned from JSNI method.
package-path:: getPoints(): JS value of type undefined, expected int
因为arr.get(index).setPoints(1)
我得到了同样的错误信息。怎么了?请帮忙。