What is the list of valid @SuppressWarnings warning names in Java?
The bit that come between the ("") in @SuppressWarnings("").
What is the list of valid @SuppressWarnings warning names in Java?
The bit that come between the ("") in @SuppressWarnings("").
It depends on your IDE or compiler.
Here is a list for Eclipse:
- all to suppress all warnings
- boxing to suppress warnings relative to boxing/unboxing operations
- cast to suppress warnings relative to cast operations
- dep-ann to suppress warnings relative to deprecated annotation
- deprecation to suppress warnings relative to deprecation
- fallthrough to suppress warnings relative to missing breaks in switch statements
- finally to suppress warnings relative to finally block that don’t return
- hiding to suppress warnings relative to locals that hide variable
- incomplete-switch to suppress warnings relative to missing entries in a switch statement (enum case)
- nls to suppress warnings relative to non-nls string literals
- null to suppress warnings relative to null analysis
- restriction to suppress warnings relative to usage of discouraged or forbidden references
- serial to suppress warnings relative to missing serialVersionUID field for a serializable class
- static-access to suppress warnings relative to incorrect static access
- synthetic-access to suppress warnings relative to unoptimized access from inner classes
- unchecked to suppress warnings relative to unchecked operations
- unqualified-field-access to suppress warnings relative to field access unqualified
- unused to suppress warnings relative to unused code
Others will be similar but vary.
All values are permitted (unrecognized ones are ignored). The list of recognized ones is compiler specific.
'unchecked' and 'deprecation' are required by the Java Language Specification, and so should be valid with all compilers. For Sun's compiler, running 'javac -X' gives a list of all values recognized by that version. For 1.5.0_17, the list appears to be:
The list is compiler specific. But here are the values supported in Eclipse:
- 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
- discouraged use of types matching a discouraged access rule
- emptyBlock undocumented empty block
- enumSwitch, incomplete-switch incomplete enum switch
- fallthrough possible fall-through case
- fieldHiding field hiding another variable
- finalBound type parameter with final bound
- finally finally block not completing normally
- forbidden use of types matching a forbidden access rule
- hiding macro 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 (lacking of tags //$NON-NLS-)
- noEffectAssign assignment with no effect
- null potential missing or redundant null check
- nullDereference missing null check
- over-ann missing @Override annotation
- paramAssign assignment to a parameter
- pkgDefaultMethod attempt to override package-default method
- raw usage a of raw type (instead of a parametrized type)
- semicolon unnecessary semicolon or empty statement
- serial missing serialVersionUID
- specialParamHiding constructor or setter parameter hiding another field
- static-access macro for indirectStatic and staticReceiver
- staticReceiver if a non static receiver is used to get a static field or call a static method
- super overriding a method without making a super invocation
- suppress enable @SuppressWarnings
- syntheticAccess, 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, unqualifiedField unqualified reference to field
- unused macro for unusedArgument, unusedImport, unusedLabel, unusedLocal, unusedPrivate and unusedThrown
- unusedArgument unused method argument
- unusedImport unused import reference
- unusedLabel unused label
- 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
Sun JDK (1.6) has a shorter list of supported warnings:
- deprecation Check for use of depreciated items.
- unchecked Give more detail for unchecked conversion warnings that are mandated by the Java Language Specification.
- serial Warn about missing serialVersionUID definitions on serializable classes.
- finally Warn about finally clauses that cannot complete normally.
- fallthrough Check switch blocks for fall-through cases and provide a warning message for any that are found.
- path Check for a nonexistent path in environment paths (such as classpath).
The latest available javac (1.6.0_13) for mac have the following supported warnings
- all
- cast
- deprecation
- divzero
- empty
- unchecked
- fallthrough
- path
- serial
- finally
- overrides