Using primitives directly in Nashorn
I am developing a program that uses custom scripts to customize most of the experience. One of the design implications is the fact that there is constant conversion from int / double / float to number and back. The conversion is overhead and therefore undesirable. For example:
The class that Javascript says:
class FromJava {
public float getNum() {
return 325.753;
}
}
Javascript (executed in Nashhorn with a FromJava instance already installed)
function doMath() {
print(typeOf(obj.getNum()); // Prints "number"
}
Is there a way to prevent unnecessary boxing or is this a necessary overhead of the current Nashorn implementation?
+3
source to share
No one has answered this question yet
Check out similar questions: