Java Reference
In-Depth Information
• If the superclass constructor invocation is qualified, then the
Primary
expres-
sion
p
immediately preceding “
.super
” is evaluated.
If
p
evaluates to
null
, a
NullPointerException
is raised, and the superclass constructor
invocation completes abruptly.
Otherwise, the result of this evaluation is the immediately enclosing instance of
i
with respect to
S
.
• If the superclass constructor invocation is not qualified, then:
class of
S
. Let
n
be an integer such that
O
is the
n
'th lexically enclosing class
of
C
.
The immediately enclosing instance of
i
with respect to
S
is the
n
'th lexically
enclosing instance of
this
.
Let
O
be the innermost lexically enclosing class of
S
, and let
n
be an integer
such that
O
is the
n
'th lexically enclosing class of
C
.
The immediately enclosing instance of
i
with respect to
S
is the
n
'th lexically
enclosing instance of
this
.
3.
After determining the immediately enclosing instance of
i
with respect to
S
(if
any), evaluation of the superclass constructor invocation statement proceeds by
evaluating the arguments to the constructor, left-to-right, as in an ordinary method
invocation; and then invoking the constructor.
4.
Finally, if the superclass constructor invocation statement completes normally, then
all instance variable initializers of
C
and all instance initializers of
C
are executed.
If an instance initializer or instance variable initializer
I
textually precedes another
instance initializer or instance variable initializer
J
, then
I
is executed before
J
.
Execution of instance variable initializers and instance initializers is performed re-
gardless of whether the superclass constructor invocation actually appears as an
explicit constructor invocation statement or is provided automatically. (An altern-
ate constructor invocation does not perform this additional implicit execution.)
8.8.8. Constructor Overloading
The overloading is resolved at compile time by each class instance creation expression