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

delegate an Interface to a support class

XMLWordPrintable

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



      Name: gm110360 Date: 09/06/2002


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

      FULL OPERATING SYSTEM VERSION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      I would like to delegate all of my interface
      implementations to another class or adapter, ideally
      through a new keyword. Example below:

      public interface intefaceA {
        void methodA();
        void methodB();
      }
      public class InterfaceAAdapter
        implements InterfaceA
      {
         public void methodA(){}
         public void methodB(){}
      }

      class ClassA implements InterfaceA
      {
      // new keyword here
        delegate InterfaceA myInterfaceA;
        InterfaceAAdapter myInterfaceA;
      }

      This would basically add the following methods to ClassA at
      compiletime

        methodA(){ myInterface.methodA();}
        methodB(){ myInterface.methodB();}

      It would be very simple to implement in the compiler
      (similar to Innerclasses) and would drastically clean up
      code all over the world. Take for instance java beans
      which continually use utility class for property
      management, only to expose the function via wrapper.

      I use this model of support pops-up as useful all over the
      place. This would probably solve most areas where a static
      method in an interface would be used.

      Don't force developers to rely on a tool kit for this
      support. Inner classes could also be done via raw coding.



      REPRODUCIBILITY :
      This bug can be reproduced occasionally.

      CUSTOMER WORKAROUND :
      Currently I can manually code all of the methods to
      interface.
      (Review ID: 164137)
      ======================================================================

            gbrachasunw Gilad Bracha (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: