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

Order of declarations has effect on [dep-ann] warning

XMLWordPrintable

    • generic
    • generic

      Tried on Solaris -10
      JDK :java version "1.6.0-ea" (build 1.6.0-ea-b46)

      Order of declarations has effect on [dep-ann] warning
      Please see the following code:
      <code>
      class Sample{
          //...
      }
       
      public class Foo{
          class inner11{
             Sample sample = new Sample(){
                 void myMethod(){
                 /** @deprecated */
                      class myClass{
                          //...
                      }
                  /** @deprecated */
                      int i=0;
                 }
             };
          }
      }
      </code>
      output of the code when compiled:
      <output>
      bash-3.00$ javac -Xlint Foo.java
      Foo.java:10: warning: [dep-ann] deprecated item is not annotated with @Deprecated
                      class myClass{
                      ^
      1 warning
      bash-3.00$
      </output>

      When order of
                 /** @deprecated */
                      class myClass{
                          //...
                      }
                  /** @deprecated */
                      int i=0;
      is changed to
                 void myMethod(){
                  /** @deprecated */
                      int i=0;
                 
                 /** @deprecated */
                      class myClass{
                          //...
                      }
      Then no warning is issused.
      <code>
      class Sample{
          //...
      }
       
      public class Foo{
          class inner11{
             Sample sample = new Sample(){
                 void myMethod(){
                  /** @deprecated */
                      int i=0;
                 
                 /** @deprecated */
                      class myClass{
                          //...
                      }
                 }
             };
          }
      }
      </code>
      <output>
      bash-3.00$ javac -Xlint Foo.java
      bash-3.00$
      </output>

            jjg Jonathan Gibbons
            savadhansunw Seetharama Avadhanam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: