JDK-4233889 : Would like deprecation warnings for files in current compilation
  • Type: Enhancement
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 1.2.1,1.2.2
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic,solaris_2.6
  • CPU: generic,sparc
  • Submitted: 1999-04-29
  • Updated: 2001-03-29
  • Resolved: 2001-03-29
Related Reports
Duplicate :  
Description

Name: krT82822			Date: 04/28/99


In the documentation for deprecation, it says:

Note: A deprecation warning is suppressed if the compilation 
        unit containing the deprecation is being compiled at 
        the same time as the compilation unit using the 
        deprecated class or member. This allows legacy APIs 
        to be built without warnings. There currently is no 
        other way to suppress the deprecation warnings. 

We're using deprecation internally, and explicitly don't want 
this behavior. All of our deprecated tags are put on 
interfaces for use outside old APIs, so we wouldn't get lots of 
extraneous deprecation warnings, and the multi-stage 
compilation is a real pain. Please add a command line flag 
which causes all deprecation warnings to be printed out.


4/28/99 kevin.ryan@eng -- test case submitted via subsequent email:

> Subject:  Re: (Review ID: 57605) Would like deprecation warnings for files in current build
> Date:  Wed, 28 Apr 1999 15:59:55 -0700 (PDT)
> From:   bram <###@###.###>

That's because insets() is already compiled. Try the following:
(Note that it is very very important to leave the @deprecated comment in -
it's actually used by the compiler.)

public class IsDep
{
    /**
     * @deprecated
     */
    public static void deprecatedMethod()
    {
    }
}

public class CallsDep
{
    public void someMethod()
    {
        IsDep.deprecatedMethod();
    }
}

Create each of those classes in their own separate file, then call javac
on CallsDep using -deprecation. It will cascade compilation of
IsDep but won't give any deprecation warnings. Then delete the resulting
.class files and compile just IsDep. Again, it won't give any compilation
warnings. Finally, compile CallsDep without deleting the .class file for
IsDep first. Now it will give a deprecation warning. Not giving
deprecation warnings in the first case despite giving it in the second one
is the documented behavior, which I'm willing to accept (although I'm
unclear on the reasoning behind it.) What I would like would be for a
-deprecationall or something similar to be added to the parameters for
javac so that I could purposefully make it spew deprecation information
whenever applicable.

The following is a log of me running through the test I described. Note
the different responses to the two calls to javac -deprecation
CallsDep.java.

E:\temp>dir
 Volume in drive E has no label.
 Volume Serial Number is 5C9C-8587

 Directory of E:\temp

04/28/99  03:53p        <DIR>          .
04/28/99  03:53p        <DIR>          ..
04/28/99  03:51p                   102 CallsDep.java
04/28/99  03:51p                   114 IsDep.java
               4 File(s)            216 bytes
                          3,853,410,304 bytes free

E:\temp>javac -deprecation CallsDep.java

E:\temp>dir
 Volume in drive E has no label.
 Volume Serial Number is 5C9C-8587

 Directory of E:\temp

04/28/99  03:53p        <DIR>          .
04/28/99  03:53p        <DIR>          ..
04/28/99  03:53p                   289 CallsDep.class
04/28/99  03:51p                   102 CallsDep.java
04/28/99  03:53p                   261 IsDep.class
04/28/99  03:51p                   114 IsDep.java
               6 File(s)            766 bytes
                          3,853,410,304 bytes free

E:\temp>del *.class

E:\temp>dir
 Volume in drive E has no label.
 Volume Serial Number is 5C9C-8587

 Directory of E:\temp

04/28/99  03:53p        <DIR>          .
04/28/99  03:53p        <DIR>          ..
04/28/99  03:51p                   102 CallsDep.java
04/28/99  03:51p                   114 IsDep.java
               4 File(s)            216 bytes
                          3,853,410,304 bytes free

E:\temp>javac IsDep.java

E:\temp>dir
 Volume in drive E has no label.
 Volume Serial Number is 5C9C-8587

 Directory of E:\temp

04/28/99  03:54p        <DIR>          .
04/28/99  03:54p        <DIR>          ..
04/28/99  03:51p                   102 CallsDep.java
04/28/99  03:54p                   261 IsDep.class
04/28/99  03:51p                   114 IsDep.java
               5 File(s)            477 bytes
                          3,853,410,304 bytes free

E:\temp>javac -deprecation CallsDep.java
CallsDep.java:5: Note: The method void deprecatedMethod() in class IsDep
has been deprecated.
        IsDep.deprecatedMethod();
                              ^
Note: CallsDep.java uses or overrides a deprecated API.  Please consult
the documentation for a better alternative.
1 warning

E:\temp>


-Bram
(Review ID: 57605) 
======================================================================

Comments
WORK AROUND Name: krT82822 Date: 04/28/99 Do multi-stage compilation, first the deprecated things, then the non-deprecated things. ======================================================================
11-06-2004

PUBLIC COMMENTS .
10-06-2004

EVALUATION I recommend that we enhance the -deprecation switch as follows: -deprecation:all Always display deprecation warnings -deprecation:none Never display deprecation warnings -deprecation Display deprecation warnings for external references Without the switch, the compiler would default to the present behavior. See 4304048 for further discussion of current deficiencies in the command-line functionality of the compiler. william.maddox@Eng 2000-01-28
28-01-2000