Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6594914

@SuppressWarnings("deprecation") does not not work for the type of a variable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 5.0, 7
    • Fix Version/s: 7
    • Component/s: tools
    • Subcomponent:
    • Resolved In Build:
      b130
    • CPU:
      generic, x86
    • OS:
      generic, linux
    • Verification:
      Verified

      Description

      Compilation of this code:
      package javaapplication1;

      public class Main {

          public static void main(String[] args) {
              @SuppressWarnings("deprecation")
              java.rmi.RMISecurityException ex;
          }

      }

      with "-Xlint:deprecation" produces:

      /tmp/JavaApplication1/src/javaapplication1/Main.java:7: warning: [deprecation] java.rmi.RMISecurityException in java.rmi has been deprecated

      This does not seem right, as JLS 9.6.1.5 says that:
      "a Java compiler must not report any warning identified by one of S1, ... , S k if that warning would have been generated as a result of the annotated declaration or any of its parts"

      Tested this on:
      [snip]/jdk17/bin$ ./java -version
      java version "1.7.0-ea"
      Java(TM) SE Runtime Environment (build 1.7.0-ea-b18)
      Java HotSpot(TM) Server VM (build 1.7.0-ea-b18, mixed mode)
      Another case where the @SuppressWarnings("deprecation") does not work correctly:
      package javaapplication5;

      @Deprecated
      public class A {
      }

      package javaapplication5;

      @SuppressWarnings("deprecation")
      public class B extends A { //reports "A is deprecated" here

      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mcimadamore Maurizio Cimadamore
                Reporter:
                jlahoda Jan Lahoda
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: