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

Deprecated methods should not be called from new methods.<BR>

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 1.1, 1.1.5, 1.1.6, 1.2.0
    • client-libs
    • None
    • generic, x86
    • generic, windows_95, windows_nt



      Name: mc57594 Date: 01/16/97


      Currently in the AWT, deprecated methods still contain<BR>
      functional code internally.&nbsp; Newer methods which replace the&nbsp;<BR>
      deprecated methods are calling the deprecated methods.&nbsp; As a result,&nbsp;<BR>
      a derived class cannot disable deprecated methods by throwing an<BR>
      exception or printing an error message.<BR>
      &nbsp;<BR>
      import java.awt.*;<BR>
      public class MyList extends List {<BR>
      &nbsp;&nbsp;&nbsp; // do not call this method!&nbsp; It is deprecated in
      the base class<BR>
      &nbsp;&nbsp;&nbsp; public synchronized void clear() {<BR>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new RuntimeException(&quot;java.awt.list#clear
      is deprecated&quot;);<BR>
      &nbsp;&nbsp;&nbsp; }<BR>
      &nbsp;}<BR>
      &nbsp;<BR>
      The above example will not work, since List.removeAll() will call<BR>
      List.clear(), which will now throw an exception!&nbsp; If you move the<BR>
      functionality out of List.clear() and place it in the new method<BR>
      called List.removeAll(), then I can successfully disable deprecated<BR>
      methods in my derived class.<BR>
      &nbsp;<BR>
      ======================================================================

            gsaab Georges Saab
            mchamnessunw Mark Chamness (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: