0

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 (i.e. @interface). Is it possible to know if a class is really an annotation?

3
  • 2
    try it with docs.oracle.com/javase/1.5.0/docs/api/java/lang/… Commented Apr 15, 2013 at 6:39
  • above comment can help you, also notice this: Returns true if this Class object represents an annotation type. Note that if this method returns true, isInterface() would also return true, as all annotation types are also interfaces. Commented Apr 15, 2013 at 6:54
  • Thanks, the isAnnotation() worked like a charm. Commented Apr 15, 2013 at 7:04

1 Answer 1

1

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://java.dzone.com/articles/discovering-java-annotations

It may help you

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.