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

[lworld] Javac tolerates vacuous chaining to super constructor from primitive class constructor

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • repo-valhalla
    • repo-valhalla
    • tools
    • generic
    • generic

      JEP 401 (https://openjdk.java.net/jeps/401) calls for:

      A primitive class declaration is subject to the following restrictions:

      ...

      No constructor makes a super constructor call. Instance creation will occur without executing any superclass initialization code.

      ...

      // -----

      Javac implements this "in principle", by rewriting any super() chaining attempt in

      com.sun.tools.javac.jvm.TransValues#visitMethodDef

      so no chaining happens. Instead the factory "product" gets created
      by the synthesized code (that replaces the super call) via:

       V $this = V.default;

      But tolerating express *programmer coded" super() call in the constructor is a deviation from the draft specification.

      A possible fix is to tolerate the compiler inserted super calls and issue errors only for programmer coded super calls.

      See the treatment of super() calls in enum constructors and the
      issue of the diagnostic Errors.CallToSuperNotAllowedInEnumCtor
      for precendent.

            sadayapalam Srikanth Adayapalam (Inactive)
            sadayapalam Srikanth Adayapalam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: