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

Relax constraint on placement of super() call in constructors

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: 1.1.4, 1.1.5, 1.4.1, 1.4.2, 5.0, 7
    • Fix Version/s: None
    • Component/s: specification
    • Labels:
    • Subcomponent:
    • CPU:
      x86, sparc
    • OS:
      solaris_2.5.1, windows_nt, windows_xp, windows_7

      Description

      Name: rm29839 Date: 11/19/97


      The restriction that a call to a superclass constructor can only be placed as the first statement of a constructor serves
       no purpose and should be relaxed; i.e., it should be possible to invoke a superclass constructor anywhere in a constructor,
      as long as it's guaranteed that exactly one such call is executed. I believe this could be verified using the same flow analysis t
      hat is already applied to verify the initialization of blank finals. Obviously, references to instance variables or instance
      methods would be disallowed until after the superclass constructor has returned.

      The current constraint distorts the implementation of some classes by encouraging programmers to place complex
      expressions into the argument list of a call to super(). Here's a not-atypical local example:

      super(c,HashtableUtil.
               makeHashtable(
                     new Object[] {"jobNumber","fundId","detailedFundId"},
                     new Object[] {job.jobNumber(),
                                       detailedFund.fund().id(),
                                       detailedFund.id()}));

      The above also applies to calls to forms of this(), of course.
      (Review ID: 20079)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                abuckley Alex Buckley
                Reporter:
                rmandelsunw Ronan Mandel (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: