当前位置:编程学习 > JAVA >>

一个关于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了,然后遍历呗。 --------------------编程问答-------------------- 愿闻其详
引用 1 楼 healer_kx 的回复:
那你就只能通过class loader来获得所有的types了,然后遍历呗。
--------------------编程问答-------------------- 可以通过反射机制实现 --------------------编程问答-------------------- 挨个扫描。。。
补充:Java ,  Java SE
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,