@ Suppresswarnings usage, function, and usage

Source: Internet
Author: User

Many warnings occur during Java compilation, many of which are secure, but each compilation has many warnings that affect our filtering and modification of errors. We can add them in the code.

@ Suppresswarnings ("XXXX ")

For example, @ suppresswarnings ("deprecation") indicates that the warning is not displayed when an unsupported class or method is used.

For the specific meaning of xxxx, refer to the blog

Http://www.thebuzzmedia.com/supported-values-for-suppresswarnings/

 

Update #1:All these annotations are still valid in eclipse 3.4 and 3.5, there have been no new suppresswarning arguments added in those versions of the jdt compiler.

If you are a Java developer and use the new @ suppresswarnings annotation in your code from time-to-time to suppress compiler warnings you, like me, have wondered probably about a million times alreadyJust exactly what
Are the supportedValuesThat can be used with this annotation.

The reason the list isn't easy to find is because it's compiler specific, which means sun may have a different set of supported values than say IBM, gcj or Apache harmony.

Fortunately for us, the eclipse folks have provided ented the values
TheySupport (as of eclipse 3.3), here they are for reference:

  • 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
  • Rawtypes to suppress warnings relative to un-specific types when using generics on class Params
  • 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.