0

Based on my findings from internet I understood that ClassLoader dynamically loads the .class files into JVM, and ClassLoader is part of the JRE. Then who creates the object(s) of ClassLoader and how many objects of ClassLoader are created, and where (e.g heap, stack) does it reside while loading the .class files into JVM ?

cooper
  • 603
  • 4
  • 10
  • 19

1 Answers1

0

The JVM creates a primordial classloader during JVM bootstrap. Depending on the Java version, a second classloader may then be created to load the entrypoint class and other application code.

An application can then create further classloaders as required.

... where does it reside while loading the .class files into JVM ?

It is not clear what you mean by this. A classloader object is a regular heap object, but some of the state that it manages comprises JVM data structures that are not heap objects. (The ClassLoader methods that do this are native methods.)

The process by which the primordial classloader is created is intertwined with the bootstrap process. If you really need to know how it works, you should download and read the OpenJDK source code. (And please don't ask me to explain it to you!)

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216