J2ME Programming/JVMs in MIDP

Introduction edit

This article covers the evolution of java Virtual Machines within the MIDP family of devices for the J2ME Platform. J2ME developers will find this information useful in determining whether their specific target devices support on device emulation and other beneficial information required for their application development on mobile devices.

Brief History of Java Virtual Machines in MIDP devices edit

In 1999 the K-Virtual Machine for CLDC/MIDP devices was introduced by Sun Microsystems. Motorola demoed several different devices such as pagers running KVM at the 1999 JavaOne conference("Taking it to the Streets". Taking it to the Streets: Motorola and the K Machine.).

As Sun Microsystems Engineers were tackling the problem of optimizing the Java Virtual Machine, they came up with the Java Platform Debugger Architecture("JPDA". Java Platform Debugger Architecture Home Page.) as a full debug infrastructure to assist java developers in debugging Java applications in a running mode operation using the JVM itself to provide the debugging functionality.

As mobile devices have a small memory size foot print, its obvious that the full JPDA could not be implemented in JVMs for mobile devices. Thus, the lowest part of the JPDA, Java Debug Wire Protocol(JDWP), was implemented as KVM Debug Wire Protocol(KDWP) on the KVM. Typically in the J2SE platform you would use an IDE to connect its JVM to the application JVM to collect this data that the JDWP sends from the application JVM. In the mobile J2ME development environment you would use Sun's WTK on device debug implementation or an OEM Vendors emulator to serve in place of the IDE JVM collecting data from the mobile device KVM through the KDWP conduit.

A more full mobile JDPA was researched by faculty(Jim Vallino and Hans-Peter Bischof) of Rochester Institute of Technology and students(Jon Coles, Zakir Mahomedy, Brian Koponen, Jeff Myers, John Mikucki, Aaron Deitrich)("KVMDB Project". Debugging Java Programs on the Palm Platform.) and this contributed to Sun Microsystems own KDPA product in 2001 for the KVM("Tasneem Sayeed-JavaOne Slides" (PDF). Technical Overview of K Virtual Machine(KVM) with an in depth look at new features.).

With the release of J2SE 1.3.x, Sun Microsystems introduced the Java HotSpot Java Virtual Machine technology to the java developers community. The introduction of HotSpot Optimized JVM technology to CLDC/MIDP devices(known as Monty) occurred in 2001("CLDC HI Whitepaper" (PDF). CLDC HotSpot Implementation Virtual Machine.). The HotSpot Java Virtual Machine for CDC/J2ME Platform devices was introduced in 2004.

K Virtual Machine edit

KVM1.0 and onward are based on the Spotless non optimized JVM architecture ("Spotless". The Spotless System Homepage.). All KVMs have the KVM Platform Debug Architecture and debugging is facilitated by a Debug Proxy within the Sun Microsystems WTK or vendor OEM emulator/simulator to connect the debug data and memory intensive debug operations up with occurring in the IDE JVM ("Tasneem Sayeed-JavaOne Slides" (PDF). Technical Overview of K Virtual Machine(KVM) with an in depth look at new features.).

Even with both those parts the KDWP portion on the mobile device has to be compiler turn-on enabled when the KVM for that device is first compiled and deployed to that device. Some OEM vendors did not enable this feature due to memory/speed constraints faced in their own KVM implementation on their device series. Typically, KVM has a performance of 30% to 80% when compared to the JDK 1.1.x on the desktop.

Basic KVM Features edit

  • 30% to 80% of JDK 1.1.x desktop speed performance without Just-In-Time compiling technology
  • Implemented in C
  • Small memory foot print size of 60-72kb
  • Platform independent Green Threads
  • Ports to Linux, Windows, Solaris, and Windows CE
  • Basic bytecode interpreter

KVM Platform Debug Architecture edit

  • Based on existing JDWP (Java Debug Wire Protocol)
  • Memory-intensive operations moved to Debug Agent (aka Debug Proxy) on Desktop Workstation
  • KVM implements subset of JDPW command set (KDWP)

CLDC HotSpot Implementation Virtual Machine edit

The HotSpot term from both the mobile and the desktop implementations refers to the use of an adaptive compiler to only compile bytecode into native instructions for frequent used methods (hotspots). The infrequent methods are interpreted using an optimized interpreter. This improves performance over the KVM bytecode interpreter by a factor of 5 to 7 times.

Because over 90% of all MIDP devices use the ARM family of processors, the CLDC HotSpot VM Implementation uses three methods to optimize for the ARM processors known as Thumb Mode Support.

Thumb Mode Support edit

  • VM can be compiled into 16-bit Thumb machine code
  • The dynamic adaptive compiler can be configured to generate 16-bit thumb machine code
  • The optimized interpreter was implemented using the 32-bit ARM instruction set

Another new feature when compared to the KVM is a multitasking option to run multiple threads and MIDLets in one JVM on mobile devices. These new multitasking features are implemented without relying on the underlying operating system.

This Virtual Machine implementation also implements the JDPA compliant technology first introduced in the KVM as KDWP. It is enabled by compiling the CLDC-HI VM and deploying it on a mobile device. Not every OEM vendor has made enough optimization of this CLDC-HI VM on their specific processor used and mobile hardware and thus some mobile devices with MIDP2.0 have this feature turned off.

References edit


Trademark Notices edit

J2ME, Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.