Additional Notes on Annotations


  • An annotation with no target can modify any Java element.

  • In an annotation type declaration, the only parameterized type that you can return is the Class type.

  • The @Documented meta-annotation type lets you declare an annotation type to be included in the published API generated by tools such as javadoc.

  • The @Inherited meta-annotation type means that an annotation type is inherited by all subclasses. It will be returned if you send getAnnotation to a method or class object but not if you send getdeclaredAnnotations.

  • You cannot use null as an annotation value.

  • You can modify an element only once with a given annotation. For example, you cannot supply two @Ignore annotations for a test method.

  • In order to internally support annotation types, Sun modified the Arrays class to include implementations of toString and hashCode for Arrays.



Agile Java. Crafting Code with Test-Driven Development
Agile Javaв„ў: Crafting Code with Test-Driven Development
ISBN: 0131482394
EAN: 2147483647
Year: 2003
Pages: 391
Authors: Jeff Langr

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net