Java Reference
In-Depth Information
• If C occurs in a static context, then i has no immediately enclosing instance.
• Otherwise, if the class instance creation expression occurs in a static context, then
a compile-time error occurs.
• Otherwise, the immediately enclosing instance of i is the n 'th lexically enclosing
instance of this 8.1.3 ).
Otherwise, C is an inner member class (§ 8.5 ) , and then:
• If the class instance creation expression is an unqualified class instance creation
expression, then:
♦ If the class instance creation expression occurs in a static context, then a
compile-time error occurs.
♦ Otherwise, if C is a member of an enclosing class then let O be the innermost
lexically enclosing class of which C is a member, and let n be an integer such
that O is the n 'th lexically enclosing class of the class in which the class in-
stance creation expression appears.
The immediately enclosing instance of i is the n 'th lexically enclosing instance
of this .
♦ Otherwise, a compile-time error occurs.
• Otherwise, the class instance creation expression is a qualified class instance cre-
ation expression.
The immediately enclosing instance of i is the object that is the value of the
Primary expression.
In addition, if C is an anonymous class, and the direct superclass of C , S , is an inner class,
then i may have an immediately enclosing instance with respect to S . It is determined as
follows.
If S is a local class (§ 14.3 ), then let O be the innermost lexically enclosing class of S . Let n
be an integer such that O is the n 'th lexically enclosing class of the class in which the class
instance creation expression appears. Then:
• If S occurs within a static context, then i has no immediately enclosing instance
with respect to S .
• Otherwise, if the class instance creation expression occurs in a static context, then
a compile-time error occurs.
• Otherwise, the immediately enclosing instance of i with respect to S is the n 'th lex-
ically enclosing instance of this .
Search WWH ::




Custom Search