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.
Here is a description of the build tools required by the PJES build environment.
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.
Nothing is ever as simple as it could be. The above picture is inaccurate, though not misleading.