Monday, September 23, 2013

Java vs Android::BrainBitz

While most Android applications are written in Java, there are many differences between the Java API and the Android API.Android does not use a Java Virtual Machine but another one called Dalvik.

There is no Java Virtual Machine in the Android platform. Java byte code is not executed. Instead Java classes are compiled into Dalvik executable and run on Dalvik, a specialized virtual machine (VM) designed specifically for Android. Unlike Java VMs, which are stack machines, the Dalvik VM is a register-based architecture.

Dalvik has some specific characteristics that differentiate it from other standard VMs.
The VM was designed to use less space.The constant pool has been modified to use only 32-bit indexes to simplify the interpreter.

Standard Java byte code executes 8-bit stack instructions. Local variables must be copied to or from the operand stack by separate instructions. Dalvik instead uses its own 16-bit instruction set that works directly on local variables. The local variable is commonly picked by a 4-bit 'virtual register' field.
Because the byte code loaded by the Dalvik virtual machine is not Java byte code, and of the specific way Dalvik load classes, it is not possible to load Java libraries packages as jar files, and even a specific logic must be used to load Android libraries 

No comments:

Post a Comment