mopoki’s blog

技術的なものの備忘録

JVMがどこからスタートするかが、JavaのSpecificationで書いてある所

メモ用

Javaはエントリーポイントのmain()メソッドから動く、というのは学習していたが、 どこにそれが書いてあるのかを知らなった。

以下のメモでもまだ足りないかもしれないと思うが、まずは足がかりでここは必要と思うものを上げる。

Java Virtual Machine の起動

5.2. Java Virtual Machine Startup
Chapter 5. Loading, Linking, and Initializing

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.

  • Java仮想マシンは、ブートストラップクラスローダー(§5.3.1)またはユーザー定義クラスローダー(§5.3.2)を使用して初期クラスまたはインターフェイスを作成することによって起動します。
  • 次にJava仮想マシンは、初期クラスまたはインターフェースをリンクして初期化し、public static void main (String []) を呼び出します。
  • このメソッドを呼び出すと、以降のすべてが実行されます。
  • mainメソッドを構成するJava仮想マシン命令を実行すると、追加のクラスとインターフェイスのリンク(および、結果として作成される)が発生したり、追加のメソッドが呼び出されたりする場合があります。

たぶんここだろう。