-
Bug
-
Resolution: Fixed
-
P4
-
6
-
b61
-
generic
-
generic
By JavaAdapter feature, JavaScript can implement Java interface. When script implements a Java interface, return value needs to be converted to closest Java type. For eg. if script implements java.util.Comparator interface, then the return value of compare function should be converted to int.
// a Comparator implementation that uses length comparison
var x = new java.util.Comparator() {
compare: function(o1, o2) {
return o1.length - o2.length;
}
}
In the above case, return value of compare method is int. So, script function's return value (of type java.lang.Double -- type used for all JavaScript numbers) should be converted to Java int (i.e., java.lang.Integer - the closest primitive wrapper type).
// a Comparator implementation that uses length comparison
var x = new java.util.Comparator() {
compare: function(o1, o2) {
return o1.length - o2.length;
}
}
In the above case, return value of compare method is int. So, script function's return value (of type java.lang.Double -- type used for all JavaScript numbers) should be converted to Java int (i.e., java.lang.Integer - the closest primitive wrapper type).