This is root package of the MIDP runtime environment. Classes that initialize the environment, track MIDlet state and load MIDlet suites.

Runtime Environment Components

The Runtime Environment components load and run a MIDlet suite. The native interface to run a suite is contained in the file midp.h. For the Java platform, two methods were added to the MIDletSuiteStorage class. The figure below shows the dependencies of part of the AMS that load a MIDlet suite.

Detailed Design

The top level (main) files and objects of the Runtime Environment component used to launch a MIDlet are listed in the table below.

File or Object Description
midpAMS.h Provides the public C interface to start the VM and run a suite.
MIDletSuiteStorage Provides a method to create MIDletSuite objects for installed suites.
midpInit.c Initializes the system dependent resources, including the C heap, persistent storage, and UI system.
midp_run.c Implements the functionality to run a MIDlet suite. Initializes the VM including the class path, fills in the CommandState with information needed by the MIDletSuiteLoader and starts the VM with the MIDletSuiteLoader as the first class. It repeats this process as long as the CommandState contains the name of the next suite to run.
CommandState Passes state to, and receives state from, each VM run by midp_run.c
MIDletSuite Provides the methods the rest of the system requires of a MIDlet suite, such as permission checking and getting application properties. MIDletSuite is an interface.
InternalMIDletSuiteImpl Implements the MIDletSuite interface for internally ROMized MIDlets.
MIDletStateHandler Handles processing of the runtime states of the MIDlets running in an isolated runtime environment. See the com.sun.midp.midlet package for more information.
MIDletSuiteLoader Sets up the system before a suite is run. This is the first class loaded by the VM. It takes the following steps to load and run a suite:
  • Distributes security tokens to internal classes that need them
  • Initilizes packages that have background processing requirements.
  • Gets the CommandState
  • Creates a MIDletSuite object for the suite named as the next suite to run in the CommandState and then clears the name in the CommandState
  • Loads any arguments in the CommandState into the MIDlet suite's application properties as arg-0, arg-1, and arg-2, then clear the arguments in the CommandState
  • Starts the suite and put the status in the CommandState. This is a blocking action that does not return until all of the MIDlets of the suite are destroyed.
  • Gets the name of the next suite and the last suite to run from MIDletSuiteStorage and puts them in the CommandState
  • Moves the name of the last suite in the CommandState to the name of the next suite to run in the CommandState if there is no next suite to run
  • Shuts down the event queue
  • Saves the CommandState
  • Exits the VM with a special status that is different than the one for a VM abort, so midpRun.cpp knows the VM did not abort

The figure below shows the sequence of events that occur in the runtime environment when a MIDlet is launched from the Java Application Manager.

The figure below shows the sequence of events that occur in the runtime environment when a MIDlet is destroyed.