How is the Java Bootstrap Classloader loaded? [duplicate]

别说谁变了你拦得住时间么 提交于 2019-11-28 20:57:42

问题


In java, it is said that all the classes are being loaded by classloaders.

So first of all, bootstrap classloader loads all the rt.jar classes.

So I am still confused as Classloader is also a class, so who will load this BootStrapClassloader.

Kindly explain.


回答1:


Answer : When a JVM starts up, a special chunk of machine code runs that loads the system classloader. This machine code is known as the Bootstrap / Primordial (or sometimes - Null) classloader.

It is not a Java class at all, as are all other classloaders. The bootstrap classloader is platform specific machine instructions that kick off the whole classloading process.

All classloaders, with the exception of the bootstrap classloader, are implemented as Java classes. Something must load the very first Java classloader to get the process started. Loading the first pure Java classloader is the job of the bootstrap classloader.

The bootstrap classloader also takes care of loading all of the code needed to support the basic Java Runtime Environment (JRE), including classes in the java.util and the java.lang packages.

Source: http://www.theserverside.com/tutorial/Classloaders-Demystified-Understanding-How-Java-Classes-Get-Loaded-in-Web-Applications




回答2:


The Bootstrap Classloader, being a classloader and all, is actually a part of the JVM Core and it is written in native code.

Classloaders can be objects, they need a representation too. In fact, this also allows the creation of user-defined classloaders.




回答3:


There is an idiom in English, "He pulled himself up by his bootstraps." The boot straps are the little handles of the top sides of boots and, of course, its impossible.

http://en.wikipedia.org/wiki/Booting

The article explains the process of booting a computer, which is short for bootstrapping.

What happens with every program of every type is that a loader of some sort copies some bytes into memory somewhere and begins execution at a predefined place in those bytes.

For Java, the boot strap loader may or may not be a Java class. (Someone probably knows.) But it is a program of some sort that loads the very first few classes into memory and causes the JVM to begin executing those bits of loaded Java code. Maybe it loads the JVM code itself. Maybe it just makes sure some prior bit of code loaded the JVM. Maybe, it even requires the JVM to have already been loaded and running.

Its just part of the process.




回答4:


JDK installed path: jdk\jre\lib\rt.jar

this location is called bootstrap class path. Bootstrap class loader is responsible to load classes from bootstrap class path.

Bootstrap class loader is by default available with the JVM. It is implemented in Native Language Like C and C++.




回答5:


The bootstrap class loader loads the core Java libraries located in the /jre/lib directory. This class loader, which is part of the core JVM, is written in native code.



来源:https://stackoverflow.com/questions/18214174/how-is-the-java-bootstrap-classloader-loaded

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!