Scrivio Interview library
ConceptFoundations6 min read · updated 12 November 2026

Describe the built-in class loaders in Java 9 and later: the bootstrap, platform and application (system) loaders. Which classes does each one load, and what does String.class.getClassLoader() return?

Since Java 9 there are three built-in class loaders. The bootstrap loader is built into the VM, loads core modules such as java.base, and appears as null in Java code; the platform loader, which replaced the old extension loader, loads the remaining Java SE and JDK modules that are not in the bootstrap set; and the application or system loader loads our classes from the class path and application modules from the module path. String.class.getClassLoader() returns null because String belongs to the bootstrap loader. Separately, every thread has a context class loader that frameworks use to find application classes from library code.

Why this question is asked

Class loaders decide where every class in a running program comes from, and many puzzling errors, such as a ClassNotFoundException that only happens in production or a ClassCastException between two classes with the same name, come down to which loader was involved. Interviewers ask about the built-in loaders to check that we know the modern picture after Java 9, not the Java 8 one many tutorials still describe. In this answer, we will recap what a class loader does, meet the three built-in loaders and what each loads, see how they delegate, and then look at the thread context class loader.

1A Quick Recap of Class Loaders

A class loader is an object that finds the bytes of a class, usually a class file inside a jar or a module, and turns them into a Class object the JVM can use. The JVM loads classes lazily: the first time code needs a class, the loader of the requesting class is asked to load it.

Each Class remembers the loader that defined it, and the JVM identifies a class by its name together with that defining loader. That is why loaders matter: the same class file loaded by two different loaders produces two different, incompatible classes.

2The Three Built-in Loaders

The bootstrap loader is part of the JVM itself, written in native code, not a Java object. It loads the most fundamental modules, such as java.base, which contains java.lang, java.util and java.io, plus a few others. Because it has no Java object, Java code represents it as null.

The platform loader is a Java object that loads the other Java SE and JDK modules that are not given to the bootstrap loader, such as java.sql and java.net.http in current JDKs. The exact split between bootstrap and platform modules is a JDK implementation detail and has changed between releases, so we should not rely on it. In Java 9, the platform loader replaced the extension loader, which loaded jars from jre/lib/ext.

The application loader, also called the system loader and returned by ClassLoader.getSystemClassLoader(), loads our own code: classes and jars from the class path, and application modules from the module path. It is the loader of our main class.

Java
public class Main {
public static void main(String[] args) {
System.out.println(String.class.getClassLoader()); // null (bootstrap)
System.out.println(java.sql.Connection.class.getClassLoader().getName()); // platform
System.out.println(Main.class.getClassLoader().getName()); // app
System.out.println(ClassLoader.getSystemClassLoader().getName()); // app
System.out.println(Main.class.getClassLoader().getParent().getName()); // platform
}
}
Step throughBuilt-in class loaders since Java 9
  1. Application (system) loaderclass path and application modules; our main class
  2. Platform loaderother Java SE and JDK modules, e.g. java.sql
  3. Bootstrap loaderinside the VM; java.base and core modules; null in Java

3 layers, from the top down. Step through them one at a time.

Each loader's parent is the one below it.

Notice that we print getName() for the platform and application loaders, which gives the stable names platform and app; printing the loader object itself shows an internal class name such as jdk.internal.loader.ClassLoaders$AppClassLoader followed by a hash, which varies. The first line is the answer to the interview question: String is defined by the bootstrap loader, so getClassLoader() returns null.

3How Loading Requests Are Delegated

Class loaders follow parent delegation: before a loader defines a class itself, it first gives its parent a chance. The application loader's parent is the platform loader, and the platform loader delegates to the bootstrap loader. This guarantees that core classes always come from the JDK: if someone puts a fake java.lang.String on the class path, the request reaches the bootstrap loader first, which already has the real one.

Since Java 9, delegation is also module-aware. When a built-in loader is asked for a class, it first checks whether the class's package belongs to a named module it knows, and if so it delegates straight to the loader of that module. Only packages that belong to no module are searched on the class path. For everyday purposes, the picture is still parent first, then self.

Step throughLoading com.acme.Order and java.lang.String
App loaderPlatform loaderBootstrap loader
load java.lang.String?
load java.lang.String?
defined from java.base
load com.acme.Order?
load com.acme.Order?
not found
not found
find on class path and define

8 messages in order. Play them, or step through them one at a time.

Parents are asked first, so JDK classes cannot be replaced from the class path.

4The Thread Context Class Loader

The context class loader is a separate setting: every thread holds a reference to a class loader, read with Thread.currentThread().getContextClassLoader(). It does not take part in normal loading. It exists for one awkward situation: library code loaded by a parent loader that must find classes or resources belonging to the application, which its own loader cannot see, because delegation only goes upward.

The classic example is ServiceLoader.load(Class), which by default searches the thread's context loader for providers, and older APIs such as JNDI and JAXB do the same. Frameworks set the context loader deliberately: application servers set it to each web application's loader on request threads, and Spring Boot's executable jar launcher sets it to the loader that can read the nested jars. By default it is the application loader, inherited from the thread that created the new thread.

Java
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
System.out.println(tccl.getName()); // app (by default)
ServiceLoader<Driver> drivers = ServiceLoader.load(Driver.class); // uses the context loader
// equivalent: ServiceLoader.load(Driver.class, tccl)

5Follow-up questions

What happened to the jre/lib/ext extension mechanism in Java 9?

It was removed along with the jre/lib directory layout. The extension loader became the platform loader, which loads JDK modules instead of jars from an ext folder, and setting java.ext.dirs makes the JVM refuse to start with an error that it is not supported. Jars that used to go into ext must now go on the class path, or on the module path as modules.

When would library code use the thread context class loader instead of its own loader?

When it must load classes or resources that belong to the application, for example a plugin, a provider named in configuration, or a template file, while the library itself was loaded by a parent loader such as a server's shared loader. Its own loader cannot see the child's classes, so it uses the context loader the framework set for the current thread. Well-designed APIs also let the caller pass a class loader explicitly.

Can we create our own class loaders?

Yes, by extending ClassLoader or using URLClassLoader, which application servers, plugin systems and tools like Spring Boot DevTools do. Each custom loader has a parent, usually following the same delegation model, and classes it defines are distinct from the same classes defined by any other loader.

6Conclusion

In this answer, we saw the three built-in class loaders since Java 9: the bootstrap loader inside the VM for core modules such as java.base, shown as null in Java; the platform loader, which replaced the extension loader, for the other JDK modules; and the application loader for the class path and application modules. String.class.getClassLoader() returns null for that reason. We also saw parent delegation and the thread context class loader that frameworks use to reach application classes from library code.

What to say in the interviewAbout 90 seconds aloud

Open with

Since Java 9 there are three built-in loaders. The bootstrap loader is implemented inside the JVM, not as a Java object, and it loads the core modules, java.base with java.lang and java.util and a few others.

Then, if they want more

Because there is no Java object for it, Java code sees it as null, which is why String.class.getClassLoader() returns null.

The platform loader replaced the old extension loader in Java 9; it loads the other Java SE and JDK modules that are not in the bootstrap set, such as java.sql in current JDKs, though the exact split is an implementation detail.

The application loader, also called the system loader, loads our code: classes from the class path and application modules from the module path, so it is our main class's loader.

They delegate parent first: the app loader asks the platform loader, which asks bootstrap, so a fake java.lang.String on the class path can never replace the real one; in Java 9 that lookup also became module-aware. Separately, every thread has a context class loader.

It is not used for normal loading, but library code loaded by a parent loader uses it to find application classes, for example ServiceLoader.load uses it by default, and frameworks like application servers and Spring Boot's launcher set it to the right loader for each thread.

About this answer

Last updated
12 November 2026
Versions it names
Java 9, Java 8
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Describe the built-in class loaders in Java 9 and later: the bootstrap, platform and...": https://scrivio-interview-library.netlify.app/java/class-loading/9d7d4fe825/