JDK-4825850 : deprecated warnings in implementing class
  • Type: Enhancement
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 1.4.1
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2003-02-28
  • Updated: 2003-02-28
  • Resolved: 2003-02-28
Related Reports
Duplicate :  
Description

Name: nt126004			Date: 02/28/2003


FULL PRODUCT VERSION :
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21)
Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)


FULL OPERATING SYSTEM VERSION :

n/a

ADDITIONAL OPERATING SYSTEMS :
only observed this on Linux, could not reproduce on Solaris.

A DESCRIPTION OF THE PROBLEM :
javac generates deprecated warnings when a class implements
a deprecated method from an ancestor class or interface.

Deprecation warnings should not be generated for methods that
are themselves declared "@deprecated" either simply because
the implement the method or because they call deprecated methods.

This looks very similar to bug 4750187.

EXPECTED VERSUS ACTUAL BEHAVIOR :

The provided will generate a deprecated warning while
compiling bar with javac because bar implements useless().

If a method implementation itself includes a @deprecated
directive, then the compiler should omit the deprecated
warning. Doing so makes the deprecated warnings more relevant.


STEPS TO REPRODUCE THE PROBLEM :
javac -deprecation deprecated.java
rm two/bar.class
javac -deprecation deprecated.java

ERROR MESSAGES/STACK TRACES THAT OCCUR :
javac -deprecation deprecated.java
./two/bar.java:21: warning: useless() in one.foo has been deprecated
  public foo useless() {
             ^
1 warning


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
--- foo.java ---
package one;
    
public interface foo {

 /**
   something
   	
   @deprecated no longer used.
 **/
 foo useless();

 /**
   
 **/
 foo useful();
}
--- bar.java ---
package two;

import one.foo;

public class bar implements foo {

  /**
   whatever
   
   @deprecated because i have to
  **/
  public foo useless() {
       return this;
  }

  /**
   because i want to.
  **/
  public foo useful() {
      return this;
 
  }
}
--- deprecated.java ---
import one.foo;
import two.bar;

public class deprecated {
    
    /** Creates a new instance of deprecated */
    public deprecated() {
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        foo foofoo = new bar();
    }
    
}


---------- END SOURCE ----------
(Review ID: 181583) 
======================================================================