Java Reference
In-Depth Information
This can occur, for example, if a field declaration was deleted from a class after
another class that refers to the field was compiled (§ 13.4.8 ) .
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
another class that refers to the method was compiled (§ 13.4.12 ) .
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
by an implementation of the Java Virtual Machine (§ 12.3 ) .
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.
• A static field declared by T is used and the field is not a constant variable (§ 4.12.4 ) .
T is a top level class (§ 7.6 ), and an assert statement (§ 14.10 ) lexically nested within
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.
Search WWH ::




Custom Search