Dalvik Virtual machine (DVM) is Register Architecture, designed to run on low memory, uses its own byte code and runs .Dex file (Dalvik Executable File)
Java Virtual Machine (JVM) is Stack Architecture, uses java byte code and runs .class file having JIT.
Java source code is compiled by the Java compiler into .class files. Then the dx (dexer) tool, part of the Android SDK processes the .class files into a proprietary file format called DEX that contains Dalvik bytecode.
Difference between .class and .dex file format
● In DEX all the classes of the application are packed into one file.
● All the classes in the same DEX file share field, method, etc if they are same.
● Classes from the same DEX file are loaded by the same class loader instance.
Click on the link below to view in graphic the difference between the two:
The dx tool eliminate all the redundant information that is present in the classes. The initial loading and parsing procedures that happens again and again are eliminated.
In general, a Java .class file contains a number of different method signatures used in the code. These signatures are duplicated if referenced in different Java classes.In other words, each of these classes references to the methods that takes the same arguments and the same return type. So, each one of these classes will have to include the same method signatures and hence the efforts of parsing the files are duplicated. In addition to this, there is a large number of strings included that labels the internal bits of the class files.
In the dex conversion all of the separate constant pools are collapsed into a single shared constant pool. This way not only is redundant information eliminated but storage space to store the shared constant pool is also conserved.