United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4986254 add jsr175's java.lang.SuppressWarnings
JDK-4986254 : add jsr175's java.lang.SuppressWarnings

Details
Type:
Enhancement
Submit Date:
2004-01-30
Status:
Resolved
Updated Date:
2004-02-20
Project Name:
JDK
Resolved Date:
2004-02-20
Component:
core-libs
OS:
solaris_8
Sub-Component:
java.lang
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
5.0
Fixed Versions:
5.0 (b40)

Related Reports

Sub Tasks

Description
1.5.0's javac has more warnings than previous javac compilers, and these "lint-like" warnings are very useful.  We plan to add more in subsequent releases.  To encourage their use, there should be some way to disable a warning in a particular part of the program when the programmer knows that the warning is inappropriate for the given context.  The obvious way to do this is with an annotation on the program element containing the code in question.  I propose the following annotation type in java.lang:

import java.lang.annotation.*;
import static java.lang.annotation.ElementType.*;

/**
* Indicates that the named compiler warnings should be suppressed in
* the annotated element (and in all program elements contained in the
* annotated element).   Note that the set of warnings suppressed in
* a given element is a superset of the warnings suppressed in all
* containing elements.   For example, if you annotate a class to
* suppress one warning and annotate a method to suppress another,
* both warnings will be suppressed in the method.
*
* As a matter of style, programmers should always use this annotation
* on the most deeply nested element where it is effective.  If you want
* to suppress a warning in a particular method, you should annotate that
* method rather than its class.
*/
@Target({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE})
@Retention(RetentionPolicy.SOURCE)
public @interface SuppressWarnings {
  /**
   * The set of warnings that are to be suppressed by the compiler
   * in the annotated element.  Duplicate names are prohibited, and
   * will result in a compile-time error.  The presence of unrecognized
   * warning names is <i>not</t> an error: compilers must ignore any
   * warnings they do not recognize.  They are, however, free to emit a
   * warning if an annotation contains any unrecognized warning names.
   *
   * Compiler vendors should document the warning names they support
   * in conjunction with this annotation type, and are encouraged to
   * cooperate to ensure that the same names work across multiple
   * compilers.
   */
  String[] value();
}

                                    

Comments
EVALUATION

in progress.

###@###.### 2004-01-30
                                     
2004-01-30
PUBLIC COMMENTS

...
                                     
2004-06-10
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
tiger-beta2

FIXED IN:
tiger-beta2

INTEGRATED IN:
tiger-b40
tiger-beta2


                                     
2004-06-14



Hardware and Software, Engineered to Work Together