- Comparison of Java and Android API
-
This article compare the Java and Android API and virtual machine machines.
While most Android applications are written in Java, there are many differences between the java API and the Android API, and Android does not use a Java Virtual Machine but another one called Dalvik.
Contents
Virtual machine
There is no Java Virtual Machine in the platform and Java byte code is not executed. Java classes are compiled into Dalvik executables and run on Dalvik, a specialized virtual machine 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:[1]
- The VM was slimmed down to use less space
- The constant pool has been modified to use only 32-bit indexes to simplify the interpreter
- Standard Java bytecode 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.
Moreover, according to Google, Dalvik has been designed so that a device can run multiple instances of the VM efficiently.[2]
Class library
Dalvik does not align to Java SE nor Java ME class library profiles[3][4] (e.g., Java ME classes, AWT or Swing are not supported). Instead it uses its own library[5] built on a subset of the Apache Harmony Java implementation.
Graphics and Widget library
Android does not use the Abstract Window Toolkit nor the Swing library. User Interface is built using View objects. Android use a framework similar to Swing based around
View
s rather thanJComponent
s. However, Android widgets are not JavaBeans: the Android applicationContext
must be provided to the widget at creation.Look and Feel
Android widget library does not support a Pluggable look and feel architecture; The Look and Feel of Android widgets must be embedded in the widgets themselves. There is however a limited capability to set styles and themes for an application.[6]
Layout manager
Contrary to Java where Layout managers can be applied to any container widget, Android layout behavior is encoded in the containers.[7]
See also
References
- ^ Rose, John (2008-05-31). "with Android and Dalvik at Google I/O". http://blogs.sun.com/jrose/entry/with_android_and_dalvik_at. Retrieved 2008-06-08.
- ^ Google (2009-04-13). "What is Android?". http://developer.android.com/guide/basics/what-is-android.html. Retrieved 2009-04-19.
- ^ "Google's Android SDK Bypasses Java ME in Favor of Java Lite and Apache Harmony". infoq.com. 2007-11-12. http://www.infoq.com/news/2007/11/android-java. Retrieved 2009-05-31. "Instead of providing a full version of the Java SE or Java ME Google has diverged on two fronts. First, a limited subset of the core Java packages is provided. (...) By going this route Android is following in the footsteps of another Google project GWT which uses Java as its development language but does not support the full JDK."
- ^ "Alternative to Point2D". Droid Tutorials. 2010-02-12. http://droidtutorials.blogspot.com/2010/02/alternative-to-point2d.html. Retrieved 2010-02-17. "Given that AWT is not supported in Android API, the Point2D class, which is useful for writing 2D graphics, is missing either."
- ^ "Package Index". Google. http://developer.android.com/reference/packages.html. Retrieved 2009-05-31.
- ^ "Applying Styles and Themes". Google. http://developer.android.com/guide/topics/ui/themes.html#ApplyAStyle. Retrieved 2011-09-03.
- ^ "Common Layout Objects". Google. http://developer.android.com/guide/topics/ui/layout-objects.html. Retrieved 2011-09-03.
Categories:- Mobile open source
- Android (operating system)
- Programming language comparisons
- Java programming language
Wikimedia Foundation. 2010.