This article discusses Sun’s open source CLDC HI Java virtual machine for embedded and mobile platforms, as well as its construction for computers with an ARM architecture.
CLDC HI
The Connected Limited Device Configuration HotSpot Implementation Virtual Machine (CLDC HI VM) is a high-performance Java virtual machine for resource-limited devices developed by Oracle (formerly Sun). This is one of the virtual machines for “small” devices, allowing you to run J2ME applications on devices with limited memory and computing power, for example, on mobile phones, PDAs, payment terminals, etc.
CLDC HI JVM is an optimized virtual machine that provides faster execution of bytecode and more efficient use of resources compared to other available virtual machines, such as Squawk, KVM, Maxine, CVM, etc. It is worth noting that this Java machine is oriented mainly on ARM processors. ')
As a separate product, it is not supplied, but is included in several solutions for manufacturers of relevant equipment. One version of this virtual machine was developed by Sun under the GPLv2 license, i.e. open source (the project is also named PhoneME Feature ). However, there is practically no public documentation on the assembly and launch of this virtual machine, and its development and support were practically stopped by Oracle after the takeover of Sun.
Therefore, this article provides a brief description of the CLDC HI itself and its assembly + detailed assembly instructions at the link below.
About profiles and configurations
Devices on which a J2ME application can run are determined by the supported configuration and platform profile. The configuration describes only the low-level part of the platform: the capabilities of the Java language, its virtual machine, and the base classes.
Currently there are two configurations for the Java ME platform:
CDC - Connected Device Configuration - is used with a virtual machine on devices with 32-bit architecture and requires more than 2 MB of memory. It provides more opportunities for applications compared to CLDC, but also more stringent hardware requirements.
CLDC - Connected Limited Device Configuration - used for 16-bit and 32-bit devices with limited memory. J2ME applications created with a CLDC configuration are targeted to devices with the following characteristics:
The minimum amount of ROM: 128 kilobytes for CLDC 1.0, 160 kilobytes for CLDC 1.1
The minimum amount of RAM: 32 kilobytes
Processor: 16-bit or 32-bit
Low power consumption
Connection to the network, including wireless, with unstable connection and limited data transfer rate, etc.
The higher level part of the platform is the profile. It is assumed that the profile will be set for each major class of devices (mobile phones, gaming machines, home appliances). Those. Profile defines the type of devices supported by the application. The profile complements the configuration with specific classes that define the scope of the device.
There are two CLDC profiles defined in J2ME: KJava and Mobile Information Device Profile (MIDP). For CDC, a template profile is available on which to build your own Foundation Profile.
The platform consisting of CLDC and MIDP is fairly common in the mobile phone market. It should be noted that CLDC HI is also based on the CLDC 1.1 configuration (JSR 118) and MIDP 2.1 profile (JSR 139).
CLDC HI assembly
This virtual machine is very useful when you need to transfer a mobile application to a device that does not support the Java platform. Therefore, this article describes the CLDC HI java build, including:
The minimum set of products required for assembly and compilation;
Setting up a cross-compilation environment based on gcc and binutils;
Localized and fixed source code errors related to incomplete backward compatibility of build tools;
Compilation keys for running on a platform with an ARM architecture.
Actually we go to the repository of the PhoneME project , whose structure is displayed below, and take the necessary basic components: cldc, midp, pscl, tools. If you need to expand the functionality of the Java machine, then take the corresponding JSR packages from the repository. They will be assembled with the midp.
Build a MIDP profile (build JSR packages if necessary).
For more detailed instructions on building on Linux under ARM can be found here: build CLDC HI
After a successful build, we have an output containing the assembled components, which we then transfer to the target device.
Run on Paspberry Pi
A single board computer Raspberry Pi with an ARM processor was used as a target device for testing the performance.
A Jar file is sent to the JVM input, which, in turn, is processed by the Midlet installer and provides an individual number for each application (see CLDC HI build for details). Then the CLDC HI JVM is launched with the application number and a frameBuffer is created, which displays the screen image of the device. The following demonstrates the work of a java-snake game using CLDC HI on the Raspberry Pi.
PS: the article is written on the results of course work at the Faculty of Mathematics and Mechanics of St. Petersburg State University. Completed Sarmanova S.G. Scientific adviser Polozov VS