Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the Classloader part of the JVM or in the JRE?

I am relatively new to java, so forgive me if this question might seem "Silly". I know that the JVM (Java Virtual Machine) is contained within the JRE (Java Runtime Environment) but I am not sure if the classloader and Execution Engine are part of the JVM.

Most sources that I have read did not specify this. Instead, when describing the components of the JVM they only discuss the 5 components of the Runtime Data Area (i.e. Heap, JVM Stack, Method Area, PC Registers and Native Method Stack). Although my common sense tells that for it to be a complete Virtual Machine it needs the input, Memory & processing, I still need to verify the exact locations of these components.

like image 881
Dougie T Avatar asked Apr 07 '17 08:04

Dougie T


People also ask

Where is ClassLoader located in Java?

Extension ClassLoader: The Extension ClassLoader is a child of Bootstrap ClassLoader and loads the extensions of core java classes from the respective JDK Extension library. It loads files from jre/lib/ext directory or any other directory pointed by the system property java.

How does a ClassLoader work in Java?

A Java Class is stored in the form of byte code in a . class file after it is compiled. The ClassLoader loads the class of the Java program into memory when it is required. The ClassLoader is hierarchical and so if there is a request to load a class, it is delegated to the parent class loader.

What is context ClassLoader in Java?

That is, the context class loader can load the classes that the application can load. This loader is used by the Java runtime such as the RMI (Java Remote Method Invocation) to load classes and resources on behalf of the user application.


1 Answers

Based on Classloader wikipedia there are 3 types of classloaders in JRE:

  1. Bootstrap class loader

This class loader, which is part of the core JVM, is written in native code

  1. Extensions class loader

It is implemented by the sun.misc.Launcher$ExtClassLoader class

  1. System class loader

This is implemented by the sun.misc.Launcher$AppClassLoader class

So i think in conclusion: first one is in JVM the other 2 is in JRE libraries.

  • also there are some user defined classloaders which are located in different places (e.g. tomcat, etc)
like image 111
Shirin Safaeian Avatar answered Oct 07 '22 23:10

Shirin Safaeian