Is there a command line tool, preferrably in the JDK, that either prints all annotations in a classfile or takes a specific annotation as argument to print?
If so, is there an equivalent command that can be run on a jar file for a specific class contained within?
I've googled this for a while and had no luck. :(
Using the -verbose or -v flag with javap version 1.7 or later will show the retained annotations.
Example:
Correct me if im wrong, but I thought, that annotations are stripped from the classes by the compiler, unless you use the Annotation @Retention(RetentionPolicy.RUNTIME) on the Annotations itself, the information will not be preserved in the class file. If the annotations are preserved in the classfile, you can use javap (part of the jdk) to see those:
Update: This seems to need JDK7, JDK6's javap doesnt print the annotations, but you can use the following tools from the University of Washington's website to extract the Annotation Information:
Annotation-utilities