Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I call a Clojure function that takes a two-dimensional array of Strings from Java?

Basically question says it all.

When I declare a function signature in gen-class, what type do I put for a 2D array of strings?

[myFunc [XXXX] ReturnType]

what do I put for XXXX?

Update : following @Mark Topolnik's suggestion, I'm trying

#^{:static true} [myFunc [ ^"[[Ljava.lang.String;" ] clojure.lang.IFn] 

in my declaration, and I'm getting back a

java.lang.RuntimeException: Unmatched delimiter: ]

runtime exception when I try to compile it.

Update 2 : Fixed by removing the ^ from the above line. (This is in the context of declaring function signatures in a gen-class so that ^ is presumably unnecessary.)

like image 431
interstar Avatar asked Oct 19 '22 21:10

interstar


1 Answers

Multidimensional array types have no direct support in Clojure, but you can always fall back to using a String with the binary type name. In your case, this would look like the following:

[myFunc ["[[Ljava.lang.String;"] ReturnType]
like image 91
Marko Topolnik Avatar answered Oct 22 '22 11:10

Marko Topolnik