简体   繁体   English

在Java中识别注释类

[英]Identify annotation class in java

I have a utility that scans different classes in the classpath, and checks for unused classes. 我有一个实用程序,可以扫描类路径中的不同类,并检查未使用的类。

Some classes need special treatment, like interfaces and abstract classes. 有些类需要特殊对待,例如接口和抽象类。 Those can be easily identified using reflection. 可以使用反射轻松识别。 The problem arises when trying to identify a class that is an annotation class (ie @interface). 当尝试识别作为注释类的类(即@interface)时,就会出现问题。 Is it possible to know if a class is really an annotation? 是否有可能知道一个类是否真的是一个注解?

Yeah.. It's possible to know if a class is really an annotation. 是的..可能知道一个类是否真的是一个注释。 Please try this: 请尝试以下方法:

http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Class.html#isAnnotation%28%29 http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Class.html#isAnnotation%28%29

http://java.dzone.com/articles/discovering-java-annotations http://java.dzone.com/articles/discovering-java-annotations

It may help you 可能对你有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM