ryoakg
11/14/2016 - 2:20 AM

Javaのメソッドの引数には多分 primitive 型の配列を渡す様になっている。primitive wrapper じゃないので注意!!

Javaのメソッドの引数には多分 primitive 型の配列を渡す様になっている。primitive wrapper じゃないので注意!!

(into-array [1])
;; => #object["[Ljava.lang.Long;" 0x12b894b2 "[Ljava.lang.Long;@12b894b2"]
(long-array [1])
;; => #object["[J" 0x3ba142b9 "[J@3ba142b9"]
(into-array [(long 1)])
;; => #object["[Ljava.lang.Long;" 0x6d08d4b4 "[Ljava.lang.Long;@6d08d4b4"]
(into-array Long [1])
;; => #object["[Ljava.lang.Long;" 0x67dc2146 "[Ljava.lang.Long;@67dc2146"]
(into-array Long [(long 1)])
;; => #object["[Ljava.lang.Long;" 0x7df9c256 "[Ljava.lang.Long;@7df9c256"]


(int-array [1])
;; => #object["[I" 0x67821277 "[I@67821277"]
(into-array [(int 1)])
;; => #object["[Ljava.lang.Integer;" 0x33ed44c5 "[Ljava.lang.Integer;@33ed44c5"]
(into-array [(Integer. 1)])
;; => #object["[Ljava.lang.Integer;" 0x4508a856 "[Ljava.lang.Integer;@4508a856"]
(into-array Integer [1])
;; java.lang.IllegalArgumentException: array element type mismatch
(into-array Integer [(int 1)])
;; => #object["[Ljava.lang.Integer;" 0x6784652a "[Ljava.lang.Integer;@6784652a"]


(byte-array [1])
;; => #object["[B" 0x1560d1e1 "[B@1560d1e1"]
(into-array [(byte 1)])
;; => #object["[Ljava.lang.Byte;" 0x4144ec0a "[Ljava.lang.Byte;@4144ec0a"]
(into-array [(Byte. (byte 1))])
;; => #object["[Ljava.lang.Byte;" 0x4319fd30 "[Ljava.lang.Byte;@4319fd30"]



[(seq (short-array [Short/MAX_VALUE Short/MIN_VALUE]))
 (seq (short-array [Integer/MAX_VALUE Integer/MIN_VALUE]))
 (seq (short-array [Long/MAX_VALUE Long/MIN_VALUE]))]
;; => [(32767 -32768) (-1 0) (-1 0)]

[(seq (int-array [Short/MAX_VALUE Short/MIN_VALUE]))
 (seq (int-array [Integer/MAX_VALUE Integer/MIN_VALUE]))
 (seq (int-array [Long/MAX_VALUE Long/MIN_VALUE]))]
;; => [(32767 -32768) (2147483647 -2147483648) (-1 0)]

[(seq (long-array [Short/MAX_VALUE Short/MIN_VALUE]))
 (seq (long-array [Integer/MAX_VALUE Integer/MIN_VALUE]))
 (seq (long-array [Long/MAX_VALUE Long/MIN_VALUE]))]
;; => [(32767 -32768) (2147483647 -2147483648) (9223372036854775807 -9223372036854775808)]


[(Class/forName "[B")
 (Class/forName "[S")
 (Class/forName "[I")
 (Class/forName "[J")]
;; => [[B [S [I [J]