繁体   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