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

Allow interface implementation to be delegated to an owned object

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.1
    • specification
    • x86
    • windows_2000

      Name: nt126004 Date: 04/21/2003


      A DESCRIPTION OF THE REQUEST :
      A feature of Delphi (but not C or C#) is to allow a class's implementation of one or more interfaces to be delegated to one of the classes properties. This is done using the following format in the class definition:

      TMyClass = class(TObject, IMyInterface)
      ... (the rest of the class definition)
      public
        property MyInterface: IMyInterface read FMyInterface implements IMyInterface;
      end;

      There are many ways this could be added to Java. One possible form for this might be something like this:

      public class MyClass implements InterfaceA, InterfaceB, InterfaceC {
        private final implements InterfaceA, InterfaceB obj = new SomeObject();
      ... (the rest of the class definition)
      }

      JUSTIFICATION :
      This approach has proven quite useful in Delphi in that it allows you to come closer to true multi-inheritance without encountering many of the problems of multi-inheritance. It also allows for multiple classes to share the same implementation of an interface. It would also help to give Java a competitive edge over C#.
      (Review ID: 182667)
      ======================================================================

            abuckley Alex Buckley
            nthompsosunw Nathanael Thompson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: