Nashorn has trouble casting JS arrays to native java arrays when invoking vararg methods.
I'm calling a Java method from JS. The java method uses variable arguments...
In my JS I construct an array variable and populate the array:
var cmDyeColor = Packages.net.canarymod.api.DyeColor;
var colors = [ cmDyeColor.ORANGE, cmDyeColor.RED ];
...
cmFireWorkHelper.addStarColors(item, colors);
The last statement above generates the following error...
Caused by: java.lang.ClassCastException: Cannot cast jdk.nashorn.api.scripting.ScriptObjectMirror to [Lnet.canarymod.api.DyeColor;
at java.lang.invoke.MethodHandleImpl.newClassCastException(MethodHandleImpl.java:361)
at java.lang.invoke.MethodHandleImpl.castReference(MethodHandleImpl.java:356)
at jdk.nashorn.internal.scripts.Script$Recompilation$342$762A$\^eval\_.L:1$canaryFirework(<eval>:26)
Incidentally, this also seems to be a problem when casting to arrays of primitives e.g. [int] see http://docs.visualillusionsent.net/CanaryLib/1.2.0/src-html/net/canarymod/api/inventory/helper/FireworkHelper.html#line.350
java.runtime.name=Java(TM) SE Runtime Environment
java.vm.version=25.40-b25
user.country.format=IE
java.vm.vendor=Oracle Corporation
java.vendor.url=http://java.oracle.com/
path.separator=:
java.vm.name=Java HotSpot(TM) 64-Bit Server VM
file.encoding.pkg=sun.io
sun.java.launcher=SUN_STANDARD
sun.os.patch.level=unknown
java.vm.specification.name=Java Virtual Machine Specification
java.runtime.version=1.8.0_40-b25
java.awt.graphicsenv=sun.awt.CGraphicsEnvironment
os.arch=x86_64
java.vm.specification.vendor=Oracle Corporation
os.name=Mac OS X
sun.jnu.encoding=UTF-8
java.specification.name=Java Platform API Specification
java.class.version=52.0
sun.management.compiler=HotSpot 64-Bit Tiered Compilers
os.version=10.10.3
java.specification.version=1.8
java.vm.specification.version=1.8
sun.arch.data.model=64
java.specification.vendor=Oracle Corporation
awt.toolkit=sun.lwawt.macosx.LWCToolkit
java.vm.info=mixed mode
java.version=1.8.0_40
java.vendor=Oracle Corporation
java.vendor.url.bug=http://bugreport.sun.com/bugreport/
sun.cpu.endian=little
sun.io.unicode.encoding=UnicodeBig
This is a known issue that is fixed, but it unfortunately missed the window to be included in 8u40; apologies for the inconvenience. It should work with any current Early Access build of 8u60.