Which annotations are baked in to Java?

I was looking for a list of annotations in Java that have some meaningful use and are enabled by default (without having to import anything). For example, @Deprecated, @SuppressWarning, etc. I couldn't find one though. Is it out there somewhere, or could we compile one?

Answers


Annotations in java.lang (not requiring additional import) package available in standard JDK include:

  • @Deprecated

    A program element annotated @Deprecated is one that programmers are discouraged from using, typically because it is dangerous, or because a better alternative exists.

  • @Override

    Indicates that a method declaration is intended to override a method declaration in a supertype.

  • @SuppressWarnings

    Indicates that the named compiler warnings should be suppressed in the annotated element (and in all program elements contained in the annotated element).

  • @SafeVarargs (since Java 7)

    A programmer assertion that the body of the annotated method or constructor does not perform potentially unsafe operations on its varargs parameter.

Don't forget to check out java.lang.annotation and javax.annotation packages.


First Bing result: http://en.wikipedia.org/wiki/Java_annotation


Its mainly these 3 annotation,

@Deprecated
@Override
@SuppressWarnings

But from Java 7 below was also included.

@SafeVarargs

See these links below:

http://docs.oracle.com/javase/tutorial/java/javaOO/annotations.html

http://docs.oracle.com/javase/7/docs/api/java/lang/annotation/Annotation.html


Need Your Help

How do I force a web page to ALWAYS be rendered with a pixel ratio of 1.0 (not 1.5) on iPhones and Androids?

android iphone cross-browser pixels

For example, by default, iPhones and Androids will automatically zoom the page to attempt to make it fit nicely in the frame if no viewport meta tag exists. Web sites designed for desktops will be ...

Blackberry development

android iphone mobile blackberry mobile-phones

I'm currently working on a consumer mobile application project and have read that 40% of smart phones in use are Blackberry's. This seems very high and surely shouldn't be ignored for development. I