Java Reference
In-Depth Information
A declaration d is said to be visible at point p in a program if the scope of d includes p , and
d is not shadowed by any other declaration at p .
When the program point we are discussing is clear from context, we will often simply say
that a declaration is visible .
A declaration d of a type named n shadows the declarations of any other types named n that
are in scope at the point where d occurs throughout the scope of d .
A declaration d of a field or formal parameter named n shadows, throughout the scope of
d , the declarations of any other variables named n that are in scope at the point where d
occurs.
A declaration d of a local variable or exception parameter named n shadows, throughout
the scope of d , (a) the declarations of any other fields named n that are in scope at the point
where d occurs, and (b) the declarations of any other variables named n that are in scope at
the point where d occurs but are not declared in the innermost class in which d is declared.
A declaration d of a method named n shadows the declarations of any other methods named
n that are in an enclosing scope at the point where d occurs throughout the scope of d .
A package declaration never shadows any other declaration.
A type-import-on-demand declaration never causes any other declaration to be shadowed.
A static-import-on-demand declaration never causes any other declaration to be shadowed.
A single-type-import declaration d in a compilation unit c of package p that imports a type
named n shadows, throughout c , the declarations of:
• any top level type named n declared in another compilation unit of p
• any type named n imported by a type-import-on-demand declaration in c
• any type named n imported by a static-import-on-demand declaration in c
A single-static-import declaration d in a compilation unit c of package p that imports a field
named n shadows the declaration of any static field named n imported by a static-import-
on-demand declaration in c , throughout c .
A single-static-import declaration d in a compilation unit c of package p that imports a
method named n with signature s shadows the declaration of any static method named n
with signature s imported by a static-import-on-demand declaration in c , throughout c .
A single-static-import declaration d in a compilation unit c of package p that imports a type
named n shadows, throughout c , the declarations of:
Search WWH ::




Custom Search