How is it possible to work with int values in jsni methods?
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;
}-*/;
}
I am using this in a method combined with a JsArray
public static boolean moreThanZeroPoints(JsArray<Person> arr, int index){
if(arr.get(index).getPoints() > 0){
return true;
}
return false;
}
In arr.get(index).getPoints()
gives the following error-message:
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
For arr.get(index).setPoints(1)
i get the same error-message.
What is wrong?
Please help.
JavaScriptObject
subclass I suppose?) What does "doesn't work" mean? (i.e. what does the code that calls these methods look like? what's the expected result? what's the actual result?) - Thomas Broyerarr.get(index)
... without checking ifarr
has value on that index which leads possibly to some kind of OutOfBoundsException. I corrected yoursetPoints
method's returning type tovoid
because I thought it was just an erratum. If you have copied it right from your code then please revise that. - qben