Java Reference
In-Depth Information
This can occur, for example, if a field declaration was deleted from a class after
•
NoSuchMethodError
: A symbolic reference has been encountered that refers to a spe-
cific method of a specific class or interface, but the class or interface does not con-
tain a method of that signature.
This can occur, for example, if a method declaration was deleted from a class after
Additionally, an
UnsatisfiedLinkError
, a subclass of
LinkageError
, may be thrown if a class de-
clares a
native
method for which no implementation can be found. The error will occur if
the method is used, or earlier, depending on what kind of resolution strategy is being used
12.4. Initialization of Classes and Interfaces
Initialization
of a class consists of executing its static initializers and the initializers for
stat-
ic
fields (class variables) declared in the class.
Initialization
of an interface consists of executing the initializers for fields (constants) de-
clared in the interface.
Before a class is initialized, its direct superclass must be initialized, but interfaces imple-
mented by the class are not initialized. Similarly, the superinterfaces of an interface are not
initialized before the interface is initialized.
12.4.1. When Initialization Occurs
A class or interface type
T
will be initialized immediately before the first occurrence of any
one of the following:
•
T
is a class and an instance of
T
is created.
•
T
is a class and a
static
method declared by
T
is invoked.
• A
static
field declared by
T
is assigned.
T
(§
8.1.3
) is executed.
A reference to a
static
field (§
8.3.1.1
) causes initialization of only the class or interface that
actually declares it, even though it might be referred to through the name of a subclass, a
subinterface, or a class that implements an interface.