Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1045599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:00:35+00:00 2026-05-16T16:00:35+00:00

I moved to a new machine which has the latest Sun’s Java compiler and

  • 0

I moved to a new machine which has the latest Sun’s Java compiler and noticed some warnings in the existing Java 6 code. The Eclipse IDE, suggested that I annotate the assignment with:

@SuppressWarnings("rawtypes")

For example:

class Foo<T> {
...
}
...
@SuppressWarnings("rawtypes")
Foo foo = new Foo();

When I moved back to the machine with the older compiler (JDK 1.6.0_20), I have noticed that this older compiler now warns about the suppression of “rawtypes” warnings, claiming that this suppression is unsupported and proposing to replace it with @SuppressWarnings(“unchecked”). Also, there were some places which the newest compiler, by default, made me to put both “unchecked” and “rawtypes” – compiling that code with the older compiler reproduces the same warning.

How can I enforce backward/forward compatibility between the two, so that neither compiler produces warnings?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T16:00:36+00:00Added an answer on May 16, 2026 at 4:00 pm

    You can use the @SuppressWarnings("unchecked") which is supported by both the eclipse compiler and javac.

    But remember the @SuppressWarnings annotation is used by your compiler which can have its own values. The JLS only forces the compiler to understand the values “unchecked” and “deprecated” (for now).

    Compiler vendors should document the warning names they support in conjunction with this annotation type. They are encouraged to cooperate to ensure that the same names work across multiple compilers.

    If you use Helios, you will need to set a specific option to allow @SuppressWarnings("unchecked") instead of @SuppressWarnings("rawtypes"),

    In case it is not possible to update the code with the new token, the suppressRawWhenUnchecked=true system property can be set when starting Eclipse.


    Resources :

    • JLS – @SuppressWarnings()
    • Eclipse JDT (Java Compiler, New “rawtypes” token for @SuppressWarnings annotation)

    EDIT: Here is the now unavailable knol article that was used as a reference, originally written by Alex Miller.

    @SuppressWarnings Annotation in Java

    Standard annotation for suppressing various warnings

    The SuppressWarnings annotation was added as a standard annotation in Java SE 5.

    Definition

    The @SuppressWarnings annotation is defined in the Java Language Specification section 9.6.1.5. This section states:

    The annotation type SuppressWarnings supports programmer control over warnings otherwise issued by the Java compiler. It contains a single element that is an array of String. If a program declaration is annotated with the annotation @SuppressWarnings(value = {S1, ... , Sk}), then a Java compiler must not report any warning identified by one of S1, … , Sk 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“.

    The subsequent section on @Deprecation also mentions that these warnings can be suppressed with @SuppressWarnings("deprecation").

    Valid Warning Types

    The only two warning strings that are mentioned in the specification itself are “unchecked” and “deprecation”. However, the Sun JDK uses a larger set of strings in the compiler. You can determine the current set by executing:

    javac -X
    

    which will show you (among other things) the valid settings for -Xlint.

    For example, Sun JDK 1.5 shows:

    • all – suppress all warnings from this code
    • deprecation – suppress warnings from using deprecated code
    • unchecked – suppress warnings from an unchecked call or an unchecked cast
    • fallthrough – suppress warnings if a switch falls through without finding a valid case (and no default)
    • path –
    • serial – suppress warnings if a Serializable class does not define a serialVersionUID
    • finally – suppress warnings from return within a finally (which will ignore return with the try)

    And Sun JDK 1.6 adds:

    • cast
    • divzero – suppress warnings if integer divide by zero is detected
    • empty
    • overrides
    • none

    IDEs and static analysis tools typically support a large number of other possible values for @SuppressWarnings. These values correspond to specific static analysis checks performed by the IDE.

    Eclipse

    The Eclipse warning values for Eclipse 3.3 are documented in the JDT docs.

    • all – suppress all warnings
    • boxing – suppress warnings relative to boxing/unboxing operations
    • cast – suppress warnings relative to cast operations
    • dep-ann – suppress warnings relative to deprecated annotation
    • deprecation – suppress warnings relative to deprecation
    • fallthrough – suppress warnings relative to missing breaks in switch statements
    • finally – suppress warnings relative to finally block that don’t return
    • hiding – suppress warnings relative to locals that hide variable
    • incomplete-switch – suppress warnings relative to missing entries in a switch statement (enum case)
    • nls – suppress warnings relative to non-nls string literals
    • null – suppress warnings relative to null analysis
    • restriction – suppress warnings relative to usage of discouraged or forbidden references
    • serial – suppress warnings relative to missing serialVersionUID field for a serializable class
    • static-access – suppress warnings relative to incorrect static access
    • synthetic-access – suppress warnings relative to unoptimized access from inner classes
    • unchecked – suppress warnings relative to unchecked operations
    • unqualified-field-access – suppress warnings relative to field access unqualified
    • unused – suppress warnings relative to unused code

    IntelliJ

    NetBeans

    Examples

    An example of specifying a single warning:

    @SuppressWarnings("unchecked")
    public void methodWithScaryWarnings() {
        List rawList = new ArrayList();
        List<String> stringList = (List<String>)rawList;
    }
    

    An example of using two warnings:

    @SuppressWarnings({"unchecked","deprecation"})
    public void methodWithScaryWarnings() {
        callDeprecatedMethod();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've just moved onto a new machine. On my old work horse, I had
I recently got a new machine at work, and moved from XP 32 Bits
I'm reviewing Java code that essentially is a recurring process that moves/reads/parses some files
Recently I moved on a brand new machine 64-bit Windows 7. But when I
I've moved to a new project team and while going over the codebase, found
I've got a new website moved to my server. This website uses PHP and
I recently moved a friends blog onto his new web hosts but unfortunately the
I moved a VS Solution file from an old PC to a new PC.
I recently moved my main website into a new folder: The websites was in
So i have just moved everything from my localhost to a new online server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.