Java Bootstrap Classloader 是如何加载的?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18214174/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How is the Java Bootstrap Classloader loaded?
提问by Sunny Gupta
In java, it is said that all the classes are being loaded by classloaders.
在java中,据说所有的类都被类加载器加载。
So first of all, bootstrap classloader loads all the rt.jar classes.
所以首先,引导类加载器加载所有 rt.jar 类。
So I am still confused as Classloader is also a class, so who will load this BootStrapClassloader.
所以我仍然很困惑,因为Classloader也是一个类,那么谁来加载这个BootStrapClassloader。
Kindly explain.
请解释一下。
回答by Fritz
The Bootstrap Classloader, being a classloader and all, is actually a part of the JVM Core and it is written in native code.
该引导类加载器,是一个类加载器和所有,实际上是JVM核心的一部分,它是写在本地代码。
Classloaders can be objects, they need a representation too. In fact, this also allows the creation of user-defined classloaders.
类加载器可以是对象,它们也需要表示。事实上,这也允许创建用户定义的类加载器。
回答by Lee Meador
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
http://en.wikipedia.org/wiki/Booting
The article explains the process of booting a computer, which is short for bootstrapping.
这篇文章解释了启动计算机的过程,它是 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.
对于 Java,引导加载程序可能是也可能不是 Java 类。(有人可能知道。)但它是某种程序,它将最开始的几个类加载到内存中,并使 JVM 开始执行那些加载的 Java 代码。也许它会加载 JVM 代码本身。也许它只是确保一些先前的代码加载了 JVM。也许,它甚至需要 JVM 已经加载并运行。
Its just part of the process.
它只是过程的一部分。
回答by Raúl
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.
答:当 JVM 启动时,会运行一段特殊的机器代码来加载系统类加载器。这个机器码被称为Bootstrap/ Primordial(或有时 - Null)类加载器。
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.
它根本不是 Java 类,与所有其他类加载器一样。引导类加载器是平台特定的机器指令,它启动整个类加载过程。
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.
所有类加载器,除了引导类加载器,都是作为 Java 类实现的。必须加载第一个 Java 类加载器才能启动进程。加载第一个纯 Java 类加载器是引导类加载器的工作。
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.
引导类加载器还负责加载支持基本 Java 运行时环境 (JRE) 所需的所有代码,包括 java.util 和 java.lang 包中的类。
来源:http: //www.theserverside.com/tutorial/Classloaders-Demystified-Understanding-How-Java-Classes-Get-Loaded-in-Web-Applications
回答by Swapnil Kumawat
JDK installed path: jdk\jre\lib\rt.jar
JDK安装路径: 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++.
Bootstrap 类加载器默认可用于 JVM。它是在像 C 和 C++ 这样的本地语言中实现的。