In Java, is it possible for a super constructor invocation actually invoke a constructor in the calling class?

Posted by John Assymptoth on Stack Overflow See other posts from Stack Overflow or by John Assymptoth
Published on 2011-01-08T17:38:22Z Indexed on 2011/01/08 17:53 UTC
Read the original article Hit count: 218

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about java

Related posts about inheritance