| The Basics | Learning More |
| @SuppressWarnings | Links |
| @Override |
@Retention(RetentionPolicy.RUNTIME) means the following annotation should be retained in the class files.
@Target(ElementType.METHOD) means the following annotation only applies to methods in the class, not the whole class.
@Documents means the following annotation should show up in the Javadoc.
Now that you have defined it, you can annotate any class with it, which embeds the copyright notice in the class file, with otherwise changing the class file. It does not add any methods or fields to your class, though it is sometimes possible to get at the information through the java.lang.annotation package methods. Here is how you use it:
Here are the sorts of warning you can suppress:
| SuppressWarnings Options | |
|---|---|
| Option | Notes |
| "all" | @SuppressWarnings( "all" ) means suppress all warnings |
| "allDeprecation" | deprecation even inside deprecated code |
| "allJavadoc" | invalid or missing javadoc |
| "assertIdentifier" | occurrence of assert used as identifier |
| "boxing" | autoboxing conversion |
| "charConcat" | when a char array is used in a string concatenation without being converted explicitly to a string |
| "conditionAssign" | possible accidental boolean assignment |
| "constructorName" | method with constructor name |
| "dep-ann" | missing @Deprecated annotation |
| "deprecation" | usage of deprecated type or member outside deprecated code |
| "emptyBlock" | undocumented empty block |
| "enumSwitch" | incomplete enum switch |
| "incomplete-switch" | incomplete switch |
| "fieldHiding" | field hiding another variable |
| "finalBound" | type parameter with final bound |
| "finally" | finally block not completing normally |
| "hiding" | shorthand for fieldHiding, localHiding, typeHiding and maskedCatchBlock |
| "indirectStatic" | indirect reference to static member |
| "intfAnnotation" | annotation type used as super interface |
| "intfNonInherited" | interface non-inherited method compatibility |
| "javadoc" | invalid javadoc |
| "localHiding" | local variable hiding another variable |
| "maskedCatchBlocks" | hidden catch block |
| "nls" | non-nls string literals |
| "noEffectAssign" | for assignment with no effect |
| "null" | missing or redundant null check |
| "over-ann" | missing @Override annotation |
| "pkgDefaultMethod" | attempt to override package-default method |
| "serial" | missing serialVersionUID |
| "semicolon" | unnecessary semicolon or empty statement |
| "specialParamHiding" | constructor or setter parameter hiding another field |
| "static-access" | shorthand for indirectStatic and staticReceiver |
| "staticReceiver" | if a non static receiver is used to get a static field or call a static method |
| "suppress" | enable @SuppressWarnings |
| "syntheticAccess" | when performing synthetic access for innerclass |
| "synthetic-access" | when performing synthetic access for innerclass |
| "tasks" | enable support for tasks tags in source code |
| "typeHiding" | type parameter hiding another type |
| "unchecked" | unchecked type operation |
| "unnecessaryElse" | unnecessary else clause |
| "unqualified-field-access" | unqualified reference to field |
| "unqualifiedField" | unqualified reference to field |
| "unused" | shorthand for unusedArgument, unusedImport, unusedLocal, unusedPrivate and unusedThrown |
| "unusedArgument" | unused method argument |
| "unusedImport" | unused import reference |
| "unusedLocal" | unused local variable |
| "unusedPrivate" | unused private member declaration |
| "unusedThrown" | unused declared thrown exception |
| "uselessTypeCheck" | unnecessary cast/instanceof operation |
| "varargsCast" | varargs argument need explicit cast |
| "warningToken" | unhandled warning token in @SuppressWarnings |
/** * Get String presentation for this Thing object. * @return human readable summary of fields in Thing object. */ @Override public String toString() { return desc + " " + quantity + " " + losses; }
![]() |
and suggestions to improve this page to Roedy Green : | ||
| Canadian Mind Products | |||
| mindprod.com IP:[65.110.21.43] | |||
| Your face IP:[38.103.63.17] | The information on this page is for non-military use only. | ||
| You are visitor number 15,712. | Military use includes use by defence contractors. | ||
| You can get a fresh copy of this page from: | or possibly from your local J: drive (Java virtual drive/Mindprod website mirror) | ||
| http://mindprod.com/jgloss/annotations.html | J:\mindprod\jgloss\annotations.html | ||