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

fp.bugs 3517 Wants base class constructor to call base class methods

    XMLWordPrintable

Details

    • sparc
    • solaris_2.4

    Description

      Chris Laffra <###@###.###>

      Wants base class constructor to call base class versions of overridden methods.
      In the example below, the desired call sequence is:
           
           SuperClass::constructor(),
           SuperClass::init()
           DerivedClass::constructor()
           DerivedClass::init().

      Steps to reproduce:
      Compile and run attached code

      class SuperClass
      {
         SuperClass()
         {
            System.out.println("In SuperClass constructor");
            this.init();
         }
         
         void init()
         {
            System.out.println("In SuperClass::init()");
         }

         void fn2()
         {
            System.out.println("In SuperClass::fn2()");
            init();
         }
      };


      class DerivedClass extends SuperClass
      {

         DerivedClass()
         {
            System.out.println("In DerivedClass constructor");
            init();
         }
         
         void init()
         {
            System.out.println("In DerivedClass::init()");
         }
         
      };

      public class bug3517
      {
         public static void main(String argv[])
         {
            SuperClass sc = new DerivedClass();
            sc.fn2();
         }
      }


      /* ***** Output *****
      In SuperClass constructor
      In DerivedClass::init()
      In DerivedClass constructor
      In DerivedClass::init()
      In SuperClass::fn2()
      In DerivedClass::init()
      */

      Attachments

        Activity

          People

            fyellinsunw Frank Yellin (Inactive)
            kasmithsunw Kevin Smith (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: