一个关于Annotation的问题
一般都是通过class找到@interface注解的内容,那现在能不能通过@interface找到哪些Class应用了注解比如:
@interface
@Target(ElementType.TYPE)
public @interface MyAnnotaion {
public String code();
}
Class
@MyAnnotaion(code="T004")
public class FirstTest {
//...other code
}
我现在的想法是通过MyAnnotaion能否找到FirstTest这个带有@MyAnnotaion注释的类 --------------------编程问答-------------------- 那你就只能通过class loader来获得所有的types了,然后遍历呗。 --------------------编程问答-------------------- 愿闻其详 --------------------编程问答-------------------- 可以通过反射机制实现 --------------------编程问答-------------------- 挨个扫描。。。
补充:Java , Java SE