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

Create an Observable interface

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: 1.4.0
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:

      Description



      Name: rmT116609 Date: 05/20/2002


      FULL PRODUCT VERSION :
      java version "1.4.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
      Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

      FULL OPERATING SYSTEM VERSION :
      Microsoft Windows 2000 [Version 5.00.2195], with Service Pack 2

      A DESCRIPTION OF THE PROBLEM :
      The java.util.Observable class would be much improved if its methods were declared in an interface. Since Java only supports single inheritance, it is impossible to write a class that extends some other class *and* is also Observable.

      Here is what I'm proposing:

      Create an "observable interface" that Observable implements:

      public interface IObservable {
         << all current Observable method>>
      }

      public class Observable implements IObservable {
        << same implementation as today >>
      }

      Now, I can write a class that extends another class *and* is also an IObservable (by using a concrete Observable as an instance field):

      class MyClass Extends MyOtherClass implements IObservable {
         private Observable obs = new Observable();

         << Delegate all IObservable methods
            to the obs object. >>
      }

      This would be a very simple change to the API but would make Observables much more flexible.

      (Review ID: 146748)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                smarks Stuart Marks
                Reporter:
                rmandalasunw Ranjith Mandala (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: