我有这段代码:
(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"]])
它正确地在类foo
中创建CTest
方法,返回类型为byte[]
。但是,同样的事情会在[B
接口中创建一个返回类型为ITest
的方法。我该怎么做呢?这是Clojure中的一个错误吗?
谢谢大卫
答案 0 :(得分:2)
我不知道是否首选其他解决方案,但这样做有效:
(gen-interface
:name com.example.main.ITest
:methods [[foo [] #=(java.lang.Class/forName "[B")]])