是否可以将元数据附加到 Clojure gen-class?
我正在尝试实现一个使用需要向类添加 Java 注释的库的服务器。
从 Chas Emerick 等人即将出版的“Programming Clojure”一书(第 9.7.3 节)中,向 gen-class 方法添加注释很容易,但没有提到添加类级别的注释。
最佳答案
是的,我在这里找到了一个很好的例子:
https://github.com/clojure/clojure/blob/master/test/clojure/test_clojure/genclass/examples.clj
这是内联的一些代码,因此将来不会消失:
(gen-class :name ^{Deprecated {}
SuppressWarnings ["Warning1"] ; discarded
java.lang.annotation.Target []}
clojure.test_clojure.genclass.examples.ExampleAnnotationClass
:prefix "annot-"
:methods [[^{Deprecated {}
Override {}} ;discarded
foo [^{java.lang.annotation.Retention java.lang.annotation.RetentionPolicy/SOURCE
java.lang.annotation.Target [java.lang.annotation.ElementType/TYPE
java.lang.annotation.ElementType/PARAMETER]}
String] void]])
关于clojure - 将元数据附加到 Clojure gen-class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7703467/