In Java, is it possible for a super constructor invocation actually invoke a constructor in the calling class?
- by John Assymptoth
Super constructor invocation definition:
[Primary.] [NonWildTypeArguments] super ( ArgumentListopt ) ;
A super constructor call can be prefixed by an Primary expression. Example (taken from JLS):
class Outer {
class Inner{ }
}
class ChildOfInner extends Outer.Inner {
ChildOfInner() {
(new Outer()).super(); // (new Outer()) is the Primary
}
}
Does a Primary expression exist that makes the call to super() the invocation of a constructor of the calling class? Or Java prevents that?