Preparation involves creating the static
fields (class variables and constants) for
a class or interface and initializing such fields to the standard default values
(§4.5.4). This does not require the execution of any Java code; explicit initializers
for static
fields are executed as part of initialization (§12.4), not preparation.
Java implementations must detect the following error during preparation:
AbstractMethodError
: A class that is not declared to be abstract
has an abstract
method. This can occur, for example, if a method that is originally not abstract
is changed to be abstract
after another class that inherits the now abstract
method declaration has been compiled (§13.4.15).
If such an error is detected, then an instance of AbstractMethodError
should be
thrown at the point in the Java program that caused the class to be prepared.
Implementations of the Java Virtual Machine may precompute additional data structures at preparation time in order to make later operations on a class or interface more efficient. One particularly useful data structure is a "method table" or other data structure that allows any method to be invoked on instances of a class without requiring a search of superclasses at invocation time.