哪个 class 加载程序负责加载第一个要加载的 class?
Which class loader is responsible for loading the very first class to be loaded?
根据 this JVM specification,C
的 class 加载程序由触发加载 C
的 D
的加载程序确定:
The Java Virtual Machine uses one of three procedures to create class
or interface C
denoted by N
:
If N
denotes a nonarray class or an interface, one of the two
following methods is used to load and thereby create C
:
If D
was defined by the bootstrap class loader, then the bootstrap
class loader initiates loading of C
(§5.3.1).
If D
was defined by a user-defined class loader, then that same
user-defined class loader initiates loading of C
(§5.3.2).
- ...
那么,基本情况呢?我的意思是,将会加载第一个 class,显然 D
在这种情况下无法定义 。
在5.2. Java Virtual Machine Startup中指定:
The Java Virtual Machine starts up by creating an initial class or interface using the bootstrap class loader (§5.3.1) or a user-defined class loader (§5.3.2). The Java Virtual Machine then links the initial class or interface, initializes it, and invokes the public static method void main(String[])
. The invocation of this method drives all further execution. Execution of the Java Virtual Machine instructions constituting the main method may cause linking (and consequently creation) of additional classes and interfaces, as well as invocation of additional methods.
The initial class or interface is specified in an implementation-dependent manner. For example, the initial class or interface could be provided as a command line argument. Alternatively, the implementation of the Java Virtual Machine could itself provide an initial class that sets up a class loader which in turn loads an application. Other choices of the initial class or interface are possible so long as they are consistent with the specification given in the previous paragraph.
根据 this JVM specification,C
的 class 加载程序由触发加载 C
的 D
的加载程序确定:
The Java Virtual Machine uses one of three procedures to create class or interface
C
denoted byN
:
If
N
denotes a nonarray class or an interface, one of the two following methods is used to load and thereby createC
:
If
D
was defined by the bootstrap class loader, then the bootstrap class loader initiates loading ofC
(§5.3.1).If
D
was defined by a user-defined class loader, then that same user-defined class loader initiates loading ofC
(§5.3.2).- ...
那么,基本情况呢?我的意思是,将会加载第一个 class,显然 D
在这种情况下无法定义 。
在5.2. Java Virtual Machine Startup中指定:
The Java Virtual Machine starts up by creating an initial class or interface using the bootstrap class loader (§5.3.1) or a user-defined class loader (§5.3.2). The Java Virtual Machine then links the initial class or interface, initializes it, and invokes the public static method
void main(String[])
. The invocation of this method drives all further execution. Execution of the Java Virtual Machine instructions constituting the main method may cause linking (and consequently creation) of additional classes and interfaces, as well as invocation of additional methods.The initial class or interface is specified in an implementation-dependent manner. For example, the initial class or interface could be provided as a command line argument. Alternatively, the implementation of the Java Virtual Machine could itself provide an initial class that sets up a class loader which in turn loads an application. Other choices of the initial class or interface are possible so long as they are consistent with the specification given in the previous paragraph.