Contents | Prev | Next
J2ME CDC 1.0
Porting Guide

Porting CVM, CDC and Foundation

This information is for developers who want to port the CDC to another build or target platform.

Contents

Reference Information Files
Porting the Build Environment
Porting the HPI
Porting the Platform-Dependent Class Library Support
Porting the Java Debugger Support

Reference Information Files

If the target system provides POSIX and ANSI C libraries, you can use the reference implementation files in src/porting/posix and src/porting/ansi_c, thus reducing the amount of porting work needed.


Porting the Build Environment

This section is for developers who want to build the system on another operating system.

The build/share and build/target_name directories together form the reference build environment. The reference build process stores build-generated files under build/target_name. To set up your own build tree, make a new directory, build/your_target, and populate it with make directive files. You can start by copying and renaming the corresponding files from build/vxworks or build/linux, then editing the make variables as appropriate.

What Happens During the Reference Build?

When you run make, the following steps occur as part of the build process.
 
Step Utility Input Output
1 javac
(Java language compiler)
Must-preload .java files under src/share/classes build/target_name/btclasses/*.class
2 JavaMemberDepend
(Class member dependency checker)
build/target_name/btclasses/*.class List of classes required for transitive closure. The list is in build/target_name/generated/javavm/runtime/tranlist.
3 zip
(compression utility)
Classes listed in build/target_name/generated/javavm/runtime/tranlist build/target_name/btclasses.zip
4 javac
(Java language compiler)
  • Runtime classes
  • CVM test files in src/share/javavm/test/*.java
build/target_name/lib/cdc.jar
build/target_name/testclasses/*.class
5 zip
(compression utility)
CVM test classes in build/target_name/testclasses/*.class build/target_name/testclasses.zip
6 javah
(Native method function prototype generator)
Runtime classes JNI header files in build/target_name/generated/jni/*.h
7 JavaCodeCompact
(Class preloader)
build/target_name/btclasses.zip
  • JNI header files in build/target_name/generated/jni/*.h
  • Preloaded class data structures in build/target_name/generated/javavm/runtime/romjava*.c and romjava.h
  • Additional C file interfaces
8 C compiler Native methods and CVM source (.c) files Object files in build/target_name/obj/*.o
9 C compiler Preloaded classes in build/target_name/generated/javavm/runtime/romjava*.c Object files in build/target_name/obj/romjava*.o
10 archive utility Object files in build/target_name/obj/romjava*.o Object archive file in build/target_name/obj/libromjava.a
11 linker
  • Object files in build/target_name/obj/*.o from step 7
  • Object archive file in build/target_name/obj/libromjava.a from step 9
Linkable CDC file in build/target_name/bin/cvm.o

Build Variables

The following table describes the build variables that you may want to change if you port the build environment. These variables appear in the file build/target_name/defs_target_name.mk.
 
Option Description
AR_CREATE_FLAGS Specifies flags for the $(AR) tool to use when creating an archive.
AR_UPDATE_FLAGS Specifies flags for the $(AR) tool to use when updating an archive.
ASM_RULE Specifies the command to compile assembly language (.s) files.
AT Specifies the prefix for build commands, allowing control over whether the command is echoed. This option is set automatically to @, unless CVM_TERSEOUTPUT=true. $(AT) is usually used to prefix the commands given in other macros, such as CC_RULE.
CCDEPEND Specifies the flag to pass to the C compiler to produce header file dependency makefiles for each C file. Use -M for gcc. Note: If your C compiler does not support this feature, you must edit defs_$(CVM_TARGET).mk to set GENERATEMAKEFILES=false.
CC_RULE Command to compile C files.
CFLAGS Specifies the flags to pass to the C compiler. Note: Use the CPPFLAGS option to specify preprocessor flags.
CPPFLAGS Specifies the flags to pass to the C preprocessor. This must include $(CVM_DEFINES).
CVM The name of the CVM executable created by $LINK_RULE.
CVM_DEFINES A list of all C macro defines to add to the CPPFLAGS setting. The list is created automatically by processing the make command line arguments. For example, passing in CVM_DEBUG=true automatically adds -DCVM_DEBUG to CVM_DEFINES.
CVM_INCLUDES A list of all directories that contain included files.
CVM_JAVABIN The directory where the java, javac, javah, javadoc, and jar tools can be found.
CVMLIB The name of the CVM object file created by $LIB_RULE. This file contains all of the CVM executable code, but no preloaded classes. Use this option to get size information on the CVM executable.
CVM_RUNTIME_CLASSES A list of all classes that are part of your platform, but are not required to be preloaded. Most of the classes on this list are set up in defs.mk. Note: You need to add your platform-specific classes (if any) to this list in defs.mk.
CVM_SRCDIRS A list of all C and assembly language source directories. Most of the directories in the list are set up in defs.mk, including platform-specific directories that contain native method implemetations. Note: You need to add to this list the platform-specific directories that implement the porting layer for your platform.
CVM_TARGET The name of the target operating system, such as vxworks, linux or your_target for the reference implementation. This value locates directories specific to the target. For example, build/$(CVM_TARGET) is where the target build is done, and is also the location of any target-specific makefile, such as build/$(CVM_TARGET)/defs_$(CVM_TARGET).mk. Also, target-specific source files are in src/$(CVM_TARGET).
CVM_TARGETOBJS A list of all platform-specific object files. Any file in src/$(CVM_TARGET) should go in this list.
FILESEP The file separator character on the host operating system. For example, if your host system is a Unix or Unix-like operating environment, this should be set to the slash character (/).
LIB_FLAGS Flags to pass to the tool used to combine multiple object files into one object file.
LIB_RULE Command to combine multiple object files into one object file.
LINKFLAGS Flags to pass to the tool used to link multiple object files into an executable. On some platforms, such as VxWorks, the result is not actually an executable. Instead, the result is an object file that is linked to the VxWorks kernel later.
LINK_RULE Command to link object files into an executable.
ZIP Name of the zip tool to use. Use the full path name if it is not in the default execution path.

Porting the HPI

The CVM expects certain functionality to be available. The required functionality may be provided by the target OS or by implementation-specific code between the OS and the CVM. Required functionality includes: The HPI header files show everything that must be defined or implemented to port the VM, providing the required functionality.

To port the HPI, you need to look at the following files:

Much more detail on the HPI is available in the Host Programming Interface Reference.

Porting the Platform-Dependent Class Library Support

The reference implementations of the platform-dependent classes and native methods are in src/target_name/classes and src/target_name/native.


Porting the Java Debugger Support

The debugger support requires some porting of the networking and dynamic linking code. The reference implementation is in ext/jpda. More detail on this facility is available in the section on Using JDB with CVM.


Contents | Prev | Next
Copyright © 2000 Sun Microsystems, Inc. All Rights Reserved.

Please send comments to: jcp-cdc-comments@eng.sun.com
Sun