Java Reference
In-Depth Information
If a method name is of the form
Q.Id
, then
Q
has already been classified as a package name,
a type name, or an expression name:
• If
Q
is a package name, then a compile-time error occurs.
• Otherwise,
Q
is a type name or an expression name.
Id
is the method name to be used for method invocation.
If
Q
is a type name, then
Id
must name at least one
static
method of the type
Q
, or a
If
Q
is an expression name, then let
T
be the type of the expression
Q
.
Id
must
name at least one method of the type
T
, or a compile-time error occurs
by the rules
of §
15.12
.
Like expression names, method names may be qualified by type names, but
not by types in general. The implications are similar to those for expression
6.6. Access Control
The Java programming language provides mechanisms for
access control
, to prevent the
users of a package or class from depending on unnecessary details of the implementation
of that package or class. If access is permitted, then the accessed entity is said to be
access-
ible
.
Note that accessibility is a static property that can be determined at compile time; it de-
pends only on types and declaration modifiers.
Qualified names are a means of access to members of packages and reference types. When
(denoting a member of a package or reference type, §
6.5.5.2
) or a qualified expression
For example, a single-type-import statement (§
7.5.1
) must use a qualified type name,
so the type name being imported must be accessible from the compilation unit con-
taining the import statement. As another example, a class declaration may use a qual-
ified type name for a superclass (§
8.1.5
), and again the qualified type name must be
accessible.
Some obvious expressions are “missing” from context classification in §
6.5.1
: field
instantiated class in a qualified class instance creation (§
15.9
). Each of these expres-