Class Loader subsystem
Loading Linking Initialization
Bootstrap class loader verify Initializatio
n
Extension class loader prepare
Application class loader Resolve
• Loading: The class loader reads the “.class” file from Hard disk and loads to RAM, generate the
corresponding binary data and save it in the method area. For each .class file, JVM stores following in
method area.
Fully qualified name of the loaded class and its immediate parent class.
Whether .class file is related to Class or Interface or Enum
Modifier, variables and method information etc
• After loading .class file, JVM creates an object of type Class to represent this file in Heap memory.
• Linking : It ensures the correctness of .class file, whether this file is properly formatted and generated by a
valid compiler or not. JVM allocates the memory for class variables and initializing memory to default
values
Initialization: All static variables are assigned with their values defined in the code and static block(if any).
This is executed from top to bottom in a class and from parent to child in class hierarchy
Class Loader
Bootstrap class loader : Every JVM implementation should have bootstrap class loader, capable of loading trusted
classes. It loads core Java API classes present in JAVA_HOME/jre/lib directory
Extension class loader : It loads classes present in the extensions directory JAVA_HOME/jre/lib/ext or any other
directory specified by java.ext.dirs. System property
System or Application class loader: It is responsible to load classes from application class path
Class is loaded by
Bootstrap class loader Find
extension class loader
class
Load class Load class Class is loaded by
Find extension class loader
Extension class loader class
Load class Load class
Request to
Application class loader load a class