(. (new StringBuilder) (append (make-array (. Character TYPE) 3)))
will return something like "[C@76db09" instead of "". Since make-array
creates arrays via java.lang.reflect.Array.newInstance() which has
return type Object, StringBuilder.append(Object) will be invoked instead
of StringBuilder.append(char[]).
Now AFAIK there is no way to cast to native arrays in Clojure. In this
particular case there is a workaround: (. (new StringBuilder) (append
(new String (make-array (. Character TYPE) 3)))) but I am not sure about
the general case. [1]
Would it be good to be able to cast to native arrays in Clojure to help
with Java method invocation? E.g. something like (. (new StringBuilder)
(append (. test.Test (toCharArray a)))) where 'a' is (make-array (.
Character TYPE) 3) and test.Test.toCharArray casts Object to char[]
helps in the given example.
- Toralf
-----------------------
[1] Interestingly this workaround would not pass javac if written in
Java as there is no String(Object) constructor.