How do I pass a Long[]
array or List<Long>
to a JSNI function like this:
public native void updateData(Long[] data)/*-{
waveform.update({
data: [0.5, 1.0, 0.5, 1.0]
});
}-*/;
You can't, for various reasons.
JsArray
(or JsArrayNumber
or etc.). Same for a java.util.List
.java.lang.Long
would be an opaque object to JSNIlong
it wouldn't work, because you cannot pass a long
to JSNI. This is because not all longs can be represented as JS numbers. The equivalent of a JS Number
is double
.You have to copy your Long[]
into a JsArrayNumber
, and cope for the possible overflows when down-casting the long
value into a double
value.