Sun Logo


Architecture and Design Guide

Sun Javatrademark Wireless Client Software 2.2

Java Platform, Micro Edition

12-2008



Contents

Figures

Tables

Code Examples

Preface

1. Software Overview

Specifications and APIs

Architecture

MIDP Services and Subsystems

Components

Control Flow

Device Interactions

2. Porting Overview

Build the Software on the Reference Platform

Run TCKs on the Reference Port

Set Up and Configure Your Device Development Environment

Port the JavaCall API

Functions and Naming

Directory Structure

Understanding the Event Module

The JavaCall Porting Process

3. Hardware and Software Requirements and Constraints

Data-Type Assumptions

Resource Limitations

Native Stack Size

AMS Resource Limitations

RMS Resource Limitations

The system.jam_space Property

The DEFAULT_TOTAL_SPACE Property

The STORAGE_SUITE_LIMIT Property

Networking Resource Limitations

Graphics Resource Limitations

Other Resources

4. Managing Properties and Constants

Introduction

Design

Input Files

Properties

Modifying Properties

procedure iconsmall spaceAdding Properties

Constants

Modifying Constants

procedure iconsmall spaceAdding Constants

Changing the Output Format of Constants

5. Using the Logging, Tracing, and Assertion Services

Building to Enable the Logging, Tracing, and Assertion Services

Dynamic Logging and a MIDlet’s JAD File

Using the Logging, Tracing, and Assertion APIs

Logging

Adding Logging Channels

Tracing

Assertions

6. Porting the Record Management System

Design

Design Overview

External API and the Sandbox

Detailed Design

Design Rationale, Notes, and Considerations

Database Implementation

Detailed Design

Design Rationale, Notes, and Considerations

File System Access

Porting

7. File Organization and Naming

Source Code Organization

Naming Convention for Native Files

8. PCSL

PCSL Print Library

PCSL Memory Allocation Library

Porting malloc-Based Implementations

Porting the Heap-Based Implementation

PCSL File System Interface

PCSL Networking Library

Handles and Contexts

Alternative Networking Implementations

BSD Implementations

Socket-over-Serial Implementation

Notification

PCSL String Library

Porting Unicode Resource Names

About Radix 41 Encoding

Encoding for Non-English Resource Names

9. PutPixel Technology

Porting

Building

Testing

Tuning

10. Low-Level Graphics and Images Services

Description

External Interactions

Design

Graphics Rendering Component

Primitive Graphics Routines and Porting

Design Rationale, Notes, and Considerations

Graphics Context Component

Detailed Design

Image Component

Preprocessor Component

Decoder Component

Accessor Component

Image Storage Component

Renderer Component

Porting

Porting the Primitive Graphics Group

Porting Checklist for Primitive Graphics

Drawing Graphics Primitives

Porting Image Manipulation Group

Mutable and Immutable Images

Porting Checklist for the Image Manipulation Group

Functions to Port

procedure iconsmall spaceFacilitating Porting of the Image Manipulation Group

String and Font Drawing and Accessing Group

Alert Sound Group

Vibrate and Backlight Group

Backlight Control Methods

Backlighting Porting Interface

Strategies for Porting Backlighting

Backlighting Duration

Vibration Control Methods

Vibration Porting Interface

Vibration Support

Network Indicator

Porting Strategies

Porting Issues

Porting Verification

Error Checking

Boundary Cases

Performance Tuning

11. Implementing the High-Level UI Using Adaptive User Interface Technology

Design

Customization

Property Loading and Skin Customization

Image Usage and Support

Compressed Images Compared With Uncompressed Images

ROMized Images Compared With File System Images

Storing Image Resources in the File System

Storing Image Resources in the ROM

RAW Format Platform Specification

Support for Virtual Keyboard

Porting Steps

12. Implementing the High-Level UI Using Platform Components

Overview

Component Dependencies

Porting Steps

Testing

13. Porting the Event Processing Service

Event System

procedure iconsmall spaceSubmitting Native Events

Complete the Event Fields

Locking

Setting the MAX_EVENTS Constant

Types of Event Systems

Normal Mode

Slave Mode

Choosing Normal or Slave Mode

14. Application Management with the Java Platform

Native AMS

AMS Functionality

External Interactions With AMS

MIDlet Suite Attributes

Extended MIDlet Attributes

Inter-MIDlet Communication

Using the Pipe Communication Protocol

Downloading Dynamic Components

Configuring the AMS for Dynamic Components

Defining the Location for Dynamic Content

Security Restrictions

Support for Clamshell Devices

Porting and Customizing

Strategies for Porting the AMS

Strategies for Customizing the AMS

Things to Consider

AMS UI Implementation

Configuration Examples

Default Implementation

Custom Installer

Default Application Manager

Custom Application Manager

15. MIDlet Auto Invocation

Design

Design Overview

Push Connection States

Design Rationale, Notes, and Considerations

Porting

Protocols

Listening for Incoming Data

Message Buffering

User Interaction

MIDlet Concurrency

procedure iconsmall spaceAdding Network Protocols for Push

16. Runtime Security

Design Considerations

Native VM Startup Code and MIDlet Suite Loader

Class Loader

Security Token

Using the Service

Classes Protected by Security Tokens

Classes Used by Internal MIDlets

17. Permission Management

Design Overview

Security Handler

Permissions

Design Rationale, Notes, and Considerations

Policy Configuration

Implementations

New Permissions

procedure iconsmall spaceAdding a New Permission

New Domains

procedure iconsmall spaceAdding a New Domain

Using Permissions for Internal MIDlets

Finding the Status of a Security Certificate

18. Native Resource Management for Multitasking

Fixed Resource Policy

Open Resource Policy

Porting

19. Porting the Networking Subsystem

Generic Connection Framework and Protocol Implementations

Porting the Networking Subsystem

General Porting Considerations

Porting Considerations for HTTP

HTTP Requests Using Proxies

HTTP1.1 Persistent Connections

Porting Considerations for HTTPS

Porting HTTPS

Using the Java Wireless Client Software SSL Implementations

Porting Considerations for Server Socket

Network Monitoring

References

20. Porting the User Message Bundle Service

Design

Access Module

Behavior Module

Decoder-Encoder Component

Design Rationale, Notes, and Considerations

Porting

procedure iconsmall spaceAdding Additional Message Strings

Supporting a New Locale

procedure iconsmall spaceSupplying Locale-Specific Strings

Adding a Character Encoding

Changing the Default Screen Orientation

Customizing the Screen Display

21. Games

Engineering and Device Requirements

Design

Sprites and Tiled Layers

Example Sprite

Example Tiled Layer

Layer Manager Component

Game Canvas Component

Design Rationale, Notes, and Considerations

Porting

Porting GameCanvas

Porting Sprite and TiledLayer

A. Performance Notes

Application Startup Time

Measuring Startup Time

Handling Startup Time Variance

Starting an Application

Optimizing a MIDlet for Improved Application Startup Time

Optimizing the System for Improved Application Startup Time

Minimizing the Static Initialization of System Classes

Controlling the JIT Compiler and Ahead-of-Time Compilation

Giving the VM Hints

Disabling the Class Verifier

Caching Images

procedure iconsmall spaceCaching JAR File Entries

Runtime Performance

Performance Metrics

procedure iconsmall spaceProfiling the System

Runtime Optimizations

Caching

Indexing

Buffering

Memory Footprint

procedure iconsmall spaceMeasuring Footprint

Minimizing Static and Dynamic Footprint

Heap Capacity for the Java Platform

procedure iconsmall spaceMinimizing the Space Used by AOT and JIT Compilation

Minimizing Full Garbage Collections at Startup

Summary

Glossary

Index