开发者

Java arrays in Clojure's gen-interface

开发者 https://www.devze.com 2023-04-06 19:37 出处:网络
I have this piece of code: (ns com.example.main) (gen-class :name com.example.main.CTest :methods [ [foo [] \"[B\"]])

I have this piece of code:

(ns com.example.main)

(gen-class
  :name com.example.main.CTest
  :methods [ [foo [] "[B"]])

(defn -foo [this]
  (byte-array [(byte 1) (byte 2)]))

(gen-interface
  :name com.example.main.ITest
  :methods [ [foo [] "[B"]])

It creates the foo method in class CTest correctly, with return type byte[]. However, the same thing creates a method with 开发者_如何转开发return type [B in the ITest interface. How do I do this correctly? Is it a bug in Clojure?

Thanks, David


I don't know if some other solution is preferred, but this works:

(gen-interface
  :name com.example.main.ITest
  :methods [[foo [] #=(java.lang.Class/forName "[B")]])
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号