user1019872
user1019872

Reputation: 659

Does the Android system include a JVM?

I know the Android system includes the Dalvik virtual machine (DVM).

But I didn't understand if the Android system includes a JVM also, or is the DVM a replacement for the JVM?

Upvotes: 30

Views: 29162

Answers (2)

jado
jado

Reputation: 954

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 its 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

Upvotes: 38

CommonsWare
CommonsWare

Reputation: 1007399

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.

Upvotes: 17

Related Questions