Dalvik, the virtual machine of Android
Dalvik is the virtual machine for The Java language for applications of the Google Android operating system.
The name comes from a town in Iceland, from where the creator has origins. Dalvik is produced by the Open Handset Alliance, which includes hundreds of companies
It was created to replace the Java virtual machine because even if its license is GPL2 for the regular version, there is an exception on the mobile version Java ME, which enables Oracle to charge fees on its use.
The applications for Android are written in Java, the code is first compiled into bytecode by a regular Java compiler, and then recompiled in a code recognized by Dalvik.
So .class files are converted into .dex file. But a such file holds several classes and is comparable in size to a jar file.
Dalvik does not use the Java class library but its own based on an alternative by the foundation Apache, Harmony. Android does not use the Java ME virtual machine, nor the Java SE library.
Dalvik is a JIT engine (Just In Time), it compiles bytecode in real time, but will be replaced in the future by an AOT compiler, which compiles and stores the bytecode before execution. This new virtual machine named ART (Android RunTime) is still in development in 2014 and runs on Android 4.4 optionnally. The bytecode in the .dex file is compatible with Dalvik, so, from a developer’s perspective, there are no changes at all for applications he has written.
Dalvik vs. Java ME
There are differences between the virtual machines, mainly Dalvik runs applications in a separate environment as do browsers, which is safer.
Two statements in the Android documentation summarize the difference between Dalvik and Java Micro Edition:
"Every Android application runs in its own process, with its own instance of the Dalvik virtual machine. Dalvik has been written so that a device can run multiple VMs efficiently."
"The Dalvik VM executes files in the Dalvik Executable (.dex) format which is optimized for minimal memory footprint. The VM is register-based, and runs classes compiled by a Java language compiler that have been transformed into the .dex format by the included "dx" tool."
Also a part of the functions were transferred to the backend, in this case Linux:
"The Dalvik VM relies on the Linux kernel for underlying functionality such as threading and low-level memory management."
Source: Android developer site.
Dalvik Turbo: Created by Myriad, a compatible virtual machine they claim to be quicker than Dalvik.
ART: New virtual machine from Google, that works AOT.
VMKit: An implementation of the Java virtual machine in LLVM. Il runs Java code and works on any system.
Oracle against Dalvik
On August 12, 2010, Oracle that had acquired Sun in 2009 and thus Java, filed a complaint against Google for infringement of Copyright and patents.
The main purpose of this complaint is the Dalvik virtual machine, which according to the complaint, is using technologies that are covered by software patents that Oracle now owns.
Google responded by saying that the complaint is not founded and also that the author is not Google but the Open Handset Alliance.
The outcome of the case will focus on the validity of software patents allegedly used in Darvik.
We must understand that with the immense popularity of Android (which was sold in August 2010 at a rate of 200,000 copies per day), the virtual machine JME of Oracle can not bring them anything. Android is even ported on devices running other OS such as those of RIM!
But Java ME would it have been chosen by manufacturers as their applications engine while it is subject to royalties?
- The complaint. Oracle lost his lawsuit. It appealed, but renounced his claims on patents, in desperation, it is now claiming the Java API is copyrighted, it is a novelty.
- The point of view of the creator of Mono on the dispute between Oracle and Google.
- An analysis of the case.
- The Java ME license.