How to convert Rhino-JavaScript arrays to Java-Arrays
NativeArray arr = (NativeArray) result;
Object [] array = new Object[(int) arr.getLength()];
for (Object o : arr.getIds()) {
int index = (Integer) o;
array[index] = arr.get(index, null);
}
I'm not sure if it was the case when this question was first asked, but NativeArray
implements the java.util.List
interface. A simple way to convert to a real Java array is therefore:
Object[] array = ((List<?>) result).toArray();