Java Reference
In-Depth Information
If a program declaration is annotated with the annotation
@SuppressWarnings(value = {
S
1
, ...,
S
k
})
, then a Java compiler must not report any warning identified by one of
S
1
...
S
k
if that
warning would have been generated as a result of the annotated declaration or any of its
parts.
Unchecked warnings are identified by the string “
unchecked
”.
Compiler vendors should document the warning names they support in conjunction
with this annotation type. Vendors are encouraged to cooperate to ensure that the same
names work across multiple compilers.
9.6.3.6. @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.
A Java compiler must produce a deprecation warning when a type, method, field, or con-
structor whose declaration is annotated with the annotation
@Deprecated
is used (i.e. over-
ridden, invoked, or referenced by name), unless:
• The use is within an entity that is itself annotated with the annotation
@Deprecated
;
or
• The use is within an entity that is annotated to suppress the warning with the an-
notation
@SuppressWarnings("deprecation")
; or
• The use and declaration are both within the same outermost class.
Use of the
@Deprecated
annotation on a local variable declaration or on a parameter declar-
ation has no effect.
9.6.3.7. @SafeVarargs
are uninformative if the body of the variable arity method is well-behaved with respect to
the variable arity parameter.
The annotation type
SafeVarargs
, when used to annotate a method or constructor declaration,
makes a programmer assertion that prevents a Java compiler from reporting unchecked
warnings for the declaration or invocation of a variable arity method or constructor where
the compiler would otherwise do so due to the variable arity parameter having a non-reifi-
able element type.