Making a class available
The process of loading a class is kicked off by the invocation of the loadClass()
method on a ClassLoader
instance.
Loading a class involves two distinct steps, both of which must be successfully completed before a class can be used.
Loading the class: In this step, the
findClass()
method of aClassLoader
instance is used to locate the bytecode for this class. The binary form of a class is represented using a well defined class format and typically exists as a.class
file. However, more exotic locations may also be supported. In really mind bending scenarios, the bytecode may even be generated dynamically.Once the bytecode that represents the class has been found, the class is defined using the
defineClass()
method. In this process, the bytecode representation is converted into ajava.lang.Class
instance.Linking the class: This is an optional step that begins after a class has been successfully loaded. This process is implemented using the
resolveClass()
method...