JVM.Classloading.What is the difference between the Bootstrap ClassLoader, Platform ClassLoader (formerly Extension ClassLoader), and Application ClassLoader?

In Java, class loading follows a delegation model, where each class loader delegates the class loading request to its parent before attempting to load it itself. The three main class loaders in modern Java (JDK 9 and later) are:

1. Bootstrap ClassLoader

  • Role:
    Loads the core Java classes that are essential for running Java applications, such as classes from java.lang, java.util, etc.
  • Source:
    Loads from the JDK’s runtime image (since JDK 9, the rt.jar file was removed).
  • Implemented in:
    Native code (C/C++), as part of the JVM.
  • Parent:
    It has no parent, as it is the root class loader.

2. Platform ClassLoader (JDK 9+, formerly Extension ClassLoader)

  • Role:
    Loads classes from the Java platform modules that are not part of the core JDK, such as:
    • java.sql
    • java.xml
    • java.logging
  • Source:
    Instead of jre/lib/ext/ (which existed in JDK 8 and earlier), it now loads platform-specific modules.
  • Implemented in:
    Java (part of jdk.internal.loader.ClassLoaders$PlatformClassLoader).
  • Parent:
    Bootstrap ClassLoader.

3. Application ClassLoader (System ClassLoader)

  • Role:
    Loads user-defined classes (e.g., application code and external dependencies).
  • Source:
    Loads classes from the classpath (-cp or CLASSPATH environment variable) or module path (--module-path in JDK 9+).
  • Implemented in:
    Java (part of jdk.internal.loader.ClassLoaders$AppClassLoader).
  • Parent:
    Platform ClassLoader.
This entry was posted in Без рубрики. Bookmark the permalink.