I'm trying to port some Java code to Clojure and I ran into a situation that I can't solve.
Normally when you want call a Java constructor or method with a variable length argument you do something like this
(Fields. (into-array Comparable ["predict", "other"]))
However I found a special example where this doesn't work:
(Fields. (into-array Comparable ["predict", Double]))
Although this seems possible in Java (see below), the code above gives the following error:
IllegalArgumentException array element type mismatch java.lang.reflect.Array.set (Array.java:-2)
I tried a couple of variations, but nothing seems to work. The Java code I try to port (and the specific line that gives trouble) is here https://github.com/Cascading/pattern/blob/wip-1.0/pattern-examples/src/main/java/cascading/pattern/Main.java#L76
new Fields( "predict", Double.class )
(The constructor signature for Fields is Fields(Comparable... fields) http://docs.cascading.org/cascading/2.1/javadoc/cascading/tuple/Fields.html#Fields(java.lang.Comparable...)
I tried the following examples in the Clojure repl:
(into-array Comparable [(type Double)])
(into-array Comparable [Double/TYPE])
(into-array Comparable [Double])
=>
IllegalArgumentException array element type mismatch java.lang.reflect.Array.set (Array.java:-2)