Build Environment Implementation


The PJES build environment compiles Java, C and assembly source code and generates an executable file for a specific target system. This section describes how the PJES build environment is implemented: that is, how the PJES build environment processes and combines source files and other components to produce an executable file. It will provide background material and guidance for a licensee who needs to integrate the PJES build environment with another build environment.

Java source code is compiled using a Java compiler. The resulting class files are inspected to find references to native methods, for which C stubs are constructed. The class files are processed with JavaCodeCompact to produce a C source file whose contents correspond to the virtual machine's run-time data structures that would result if all the classes were loaded on demand. This source file is compiled and linked with target system-specific support libraries to produce an executable image file which can be downloaded and run on a target system.

Data files are processed with JavaDataCompact to produce a C source file that contains initialized data structures representing the data and a simple directory. Typically, this facility would be used to include data files that should be accessible to the target device with a minimum of trouble. For instance, a browser might include the HTML source for error-reporting pages. The PersonalJava reference implementation does not require data in this form but it can be modified to use data files that have been filized with JavaDataCompact.

Build Environment Tools

Here is a description of the build tools required by the PJES build environment.

javac
compiles Java source code into class files. The PJES build environment requires a Java compiler compatible with JDK 1.1.x.

javah
generates C language interfaces for compiled Java class files. Like JDK 1.1.x, most of the native methods in the PJAE are based on the native method interface from JDK 1.0.2. Therefore, the PJES build environment uses the -stubs option with javah to generate C stub files.

JavaCodeCompact
combines one or more Java class files and produces a target-dependent C source file that contains the given classes in a preloaded format that can be compiled and linked directly into the Java virtual machine.

JavaDataCompact
converts data files into C data structures that can be stored in ROM.

Stuffer
(optional) performs the second stage of filizing.

C compiler, assembler and linker
The PJES build environment requires an ANSI C compiler, an assembler and a linker for the target machine. The compiler should be capable of processing large machine-generated initialized data structures, like those produced by JavaCodeCompact and JavaDataCompact.

gnumake
manages the construction of software projects. Makefiles are text files that describe how to build components of a software project. The PJES build environment is organized into a group of modular makefiles that are divided between platform-independent makefiles and platform-dependent makefiles. The PJES build environment is based on gnumake.

Build Process

The following picture illustrates the build process as a work flow involving tools, source files and intermediate files that creates a PersonalJava executable file, which is then loaded to the target platform for execution.

The Java source files are first compiled to create class files which are then processed three times: once by javah to generate C stubs for their native methods, once again by javah to generate header files to allow C code to access their instance fields, and finally by JavaCodeCompact which creates a C source file that contains data structures that, when compiled, can be directly loaded into the virtual machine.

Data files can be filized by JavaDataCompact, which produces a C source file containing data structures which, when compiled, can be stored in ROM with the executable file.

Finally, all C source code is compiled and the resulting relocatable files are combined, along with any target-dependent support libraries, by the linker to produce the PersonalJava executable file.

Complications

Nothing is ever as simple as it could be. The above picture is inaccurate, though not misleading.