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

Would like deprecation warnings for files in current compilation

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.1, 1.2.2
    • tools
    • generic, sparc
    • generic, solaris_2.6



      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)
      ======================================================================

            gafter Neal Gafter (Inactive)
            kryansunw Kevin Ryan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: