java android系统是否包含JVM?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28663243/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 13:57:30  来源:igfitidea点击:

Does android system include JVM?

javaandroidjvmjitdalvik

提问by user1019872

I know android system include the Dalvik virtual machine(DVM) But i didn't understand if android system include JVM also Or DVM is a replacement for JVM? Thanks

我知道 android 系统包括 Dalvik 虚拟机 (DVM) 但我不明白 android 系统是否也包括 JVM 或者 DVM 是 JVM 的替代品?谢谢

回答by phase

Programs are commonly written in Java and compiled to bytecode for the Java virtual machine, which is then translated to Dalvik bytecode and stored in .dex (Dalvik EXecutable) and .odex (Optimized Dalvik EXecutable) files.

程序通常用 Java 编写并编译为 Java 虚拟机的字节码,然后将其转换为 Dalvik 字节码并存储在 .dex(Dalvik EXecutable)和 .odex(优化的 Dalvik EXecutable)文件中。

In short, programs are compiled into JVM bytecode, which is then interpreted into DVM bytecode. Instead of running the compiled Java code, Dalvik compiles it and then translates that code into it's own code. It in some way is a replacement for the JVM.

简而言之,程序被编译成 JVM 字节码,然后被解释成 DVM 字节码。Dalvik 不是运行已编译的 Java 代码,而是编译它,然后将该代码转换为它自己的代码。它在某种程度上是 JVM 的替代品。

An alternative runtime environment called Android Runtime (ART) was included in Android 4.4 "KitKat" as a technology preview. ART replaces Dalvik entirely in Android 5.0 "Lollipop".

作为技术预览版,Android 4.4“KitKat”中包含了一个名为 Android Runtime (ART) 的替代运行时环境。ART 在 Android 5.0“Lollipop”中完全取代了 Dalvik。

ART, the Android Runtime, replaced Dalvik in Android 5.0. ART still uses the same .dexfiles, but they are instead translated into .elf(Executable and Linkable Format) files. This is another replacement for the JVM, as Java code is compiled into JVM bytecode, then translated into DVM bytecode, then translated into an ELF file and executed.

ART,即 Android 运行时,在 Android 5.0 中取代了 Dalvik。ART 仍然使用相同的.dex文件,但它们被转换为.elf(可执行和可链接格式)文件。这是 JVM 的另一个替代品,因为 Java 代码被编译成 JVM 字节码,然后被翻译成 DVM 字节码,然后被翻译成一个 ELF 文件并执行。

@Chris Thompson does a great job explaining DVM bytecode on Understanding disassembly of Dalvik code.

@Chris Thompson 在解释Dalvik 代码反汇编上的DVM 字节码方面做得很好。

Sources: Wikipedia/ Friends / Experiences

资料来源:维基百科/朋友/经验

回答by CommonsWare

But i didn't understand if android system include JVM

但我不明白 android 系统是否包含 JVM

No.

不。

Or DVM is a replacement for JVM?

或者 DVM 是 JVM 的替代品?

The Dalvik virtual machine is for executing Android applications compiled to Dalvik bytecode. The Java virtual machine is for executing Java applications compiled to Java bytecode. Whether you consider one to be a replacement for the other is up to you.

Dalvik 虚拟机用于执行编译为 Dalvik 字节码的 Android 应用程序。Java 虚拟机用于执行编译为 Java 字节码的 Java 应用程序。您是否认为一种替代另一种取决于您。