How do you feel about Java primitive types in Clojure?

I would like to use reflection to get the Java object method from Clojure. One type of argument is the Java primitive, and I don't know how to access them from Clojure.

For example, let's say I wanted to receive String.valueOf(boolean). My closest guess was to make

(.getDeclaredMethod String "valueOf" (into-array [Boolean]))

but this fails because it is Booleannot the most primitive type, but the boxed version. I tried Boolean, but this applies to the built-in function of Clojure, and boolis undefined.

How can I reference a primitive Java type in Clojure?

+5
source share
1 answer

TYPE . :

user=> (.getDeclaredMethod String "valueOf" (into-array [Boolean/TYPE]))
#<Method public static java.lang.String java.lang.String.valueOf(boolean)>
+10

All Articles