RFR: 8278078: cannot reference super before supertype constructor has been called [v3]

Adam Sotona asotona at openjdk.java.net
Thu Dec 2 08:32:14 UTC 2021


> Pull request #4376 (with fix of 8261006: 'super' qualified method references cannot occur in a static context) regressed compilation of all inner classes using <enclosing class>.super pattern in their constructor argument to fail with: 
>  error: cannot reference super before supertype constructor has been called 
> 
> For example following source fragment cannot be compiled since that: 
> 
>     class EnclClass { 
>         class InnerClass extends Exception { 
>             InnerClass() { 
>                 super(EnclClass.super.toString()); 
>             } 
>         } 
>     } 
> 
> 
> This patch keeps throwing "cannot reference super" error for calls of <interface>.super and permits calls of <enclosing class>.super
> 
> Plus it adds a new test.
> 
> Thanks,
> Adam

Adam Sotona has updated the pull request incrementally with one additional commit since the last revision:

  fixed handling of <self>.super
  extended set of compilation validation tests
  added set of negative tests that should result in compilation error

-------------

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/6642/files
  - new: https://git.openjdk.java.net/jdk/pull/6642/files/a3964667..1d09e71c

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=6642&range=02
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=6642&range=01-02

  Stats: 142 lines in 5 files changed: 128 ins; 13 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/6642.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/6642/head:pull/6642

PR: https://git.openjdk.java.net/jdk/pull/6642


More information about the compiler-dev mailing list