当扩展一个类时,gen-class 并不会保留方法注解。
如果类 com.bar.Foo 有注解方法,那么在 MyClass 中所有注解都消失了。
(gen-class
:name com.my.MyClass
:extends com.bar.Foo
:implements (link: com.google.common.base.Supplier)
:prefix demo-
:post-init post-init)
(defn demo-post-init (link: this)
(info "initialized")
(swank.swank/start-server :port 68478))
(defn demo-get (link: _)
(get-msg))
Class<?> aClass = Class.forName("com.my.MyClass");
Method(link: ) methods = aClass.getMethods();
for (Method m : methods) {
Annotation(link: ) annotations = m.getAnnotations();
System.out.println(m.getName()+" "+annotations.length);
for (Annotation a : annotations) {
System.out.println(a.annotationType().getClass().getName());
}
}