Does android system include JVM?

22,639

Solution 1

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.

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.

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".

ART, the Android Runtime, replaced Dalvik in Android 5.0. ART still uses the same .dex files, 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.

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

Sources: Wikipedia / Friends / Experiences

Solution 2

But i didn't understand if android system include JVM

No.

Or DVM is a replacement for 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.

Share:
22,639
user1019872
Author by

user1019872

Updated on August 05, 2022

Comments

  • user1019872
    user1019872 over 1 year

    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