簡體   English   中英

JVM 和 CLR 如何知道何時啟動

[英]How does the JVM and CLR know when to kick in

只是想知道是否有人願意向我解釋 JVM、CLR 和其他“虛擬機”如何知道何時“啟動”?

我的意思是,你雙擊你的可執行文件,你的機器開始執行代碼,但在某些時候——顯然——代碼需要通知機器該代碼需要對 function 進行一些其他處理,並且需要傳遞操作碼。 那么這是如何發生的呢?

每個可執行文件首先運行非托管代碼,將控制權傳遞給 CLR(從 mscoree.dll 調用 _CorExeMain)。 然后 CLR(非托管事物)讀取/編譯/執行程序集中的代碼(並執行其他操作)。

在 .net 程序中,在啟動 CLR 的可執行文件中有一種引導加載程序。 此引導加載程序是用本機機器代碼編寫的,因此可以直接執行。 緊隨其后的是托管代碼和其他應用程序資源,然后 CLR 將使用這些資源來執行 .net 程序。

看看 JVM 可能會更清楚。 您有幾個.class 文件正在傳遞給 java.exe。 這些.class文件包含java字節碼,不能直接雙擊執行。 此外,a.jar 文件只是一個 zip 文件,其中包含 .class 和其他文件。 The file extension.jar is mapped to java.exe and when you double click it java.exe is executed with the.jar file as parameter - same process as you double click on a.doc word file and Word starts.

這在某種程度上取決於操作系統。 在ZE206A54E97690CCE50CCE872D70EE896Z中,您不能通過僅說出Z93F725A07423FE1C8888888888B48B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4BBENION無法運行ZD52387880E1EA22817A72D3759219819Z 我沒有運行任何 CLR 二進制文件,但我認為它是相同的。 In Windows (and for things like Jar files) windows has a handler that says something like "when the user opens a file that ends with.jar, run java" and similar for .net binaries.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM