RFR: 8337980: Javac allows invocation of an inherited instance method from a static method [v2]
Archie Cobbs
acobbs at openjdk.org
Mon Oct 7 23:04:57 UTC 2024
On Mon, 7 Oct 2024 20:51:17 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> one of the abstract method belongs to a class in an early construction context
I was thinking that because the two methods are inherited by a common subclass, and we are talking about an invocation `op()` in the context of that common subclass, then for any class `D` both method invocations are going to result in the same "class or interface to search" per §15.12.1 "Compile-Time Step 1: Determine Type to Search". And so then (the flexible constructors version of) §15.12.3 applies the same for both:
> Otherwise, let T be the class or interface to search (15.12.1). It is a compile-time error if ... the method invocation occurs in an early construction context (8.8.7.1) of class T...
In other words, it wouldn't be possible for one of the methods to "belong to a class in an early construction context" and the other not to... which would imply your scenario can't happen, right? Can you come up with an example where that isn't true?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20533#discussion_r1790983118
More information about the compiler-dev
mailing list