HPCJ is comprised of a compiler and a run-time system. When the compiler is invoked, it accepts Java source or class files as input and generates platform-specific executables or dynamically loaded libraries. The run-time system loads and executes the executables and dynamically loaded libraries. The run-time system also contains compiled standard Java classes, such as the java.lang package, and must be installed on systems where HPCJ-compiled applications are run.
Dynamically
loaded libraries are known as DLLs.
Dynamically loaded libraries are known as shared objects.
Although the correct term for dynamically loaded libraries differs depending on the platform, the term "DLL" will be used throughout the help information.
Compilation of Applications
A Java application typically consists of a collection of class
files organized into executables or DLLs. You can use the hpj
command and its associated options to compile Java source or
class files into an application that consists of one of the
following:
HPCJ generates two different types of Java DLLs:
In comparing simple DLLs with compound DLLs, it is worth noting that compound DLLs generally perform more efficiently for the following reasons:
Note, however, that splitting an application into multiple simple DLLs can result in the loading of fewer classes, which results in a smaller memory footprint. It also allows you to more flexibly package your application.
Additional information about compiling Java classes and packages into DLLs is found in the topic Building Executables and DLLs.
Phases of Compilation
The HPCJ compiler generates executables and DLLs from Java source
and class files using the following process:
Execution of Applications
There are generally two ways for you to run a Java application
using the HPCJ run-time system:
When the run-time system is initialized, all of the DLLs required to run the application are automatically located and loaded. First, the DLL containing the main() is located and loaded (unless the application has been built as an executable). Next, all DLLs containing classes referenced directly from the main DLL or executable are located and loaded. This continues recursively until all references are resolved. The same aggressive loading process occurs when classes that have been compiled into DLLs are dynamically loaded using the Class.forName() API or other APIs that dynamically load classes.
Note: In future releases of HPCJ, a lazy loading strategy may be implemented, where loading an individual compiled class does not result in the immediate loading of other DLLs. In this approach, DLLs that contain other directly referenced classes are loaded only on demand; for instance, on the first active use of each referenced class.
The Classpath Setting
HPCJ provides class loading
mechanisms for locating classes that have been compiled into
compound or simple DLLs. The algorithm for finding classes in
simple DLLs is analogous to a Java interpreter locating classes
by searching directories. For example, instead of looking for
files with a .class extension, HPCJ looks for files with a .jlc
extension.
HPCJ provides class loading mechanisms where compound DLLs are viewed in a variety of ways. In one view, a compound DLL is analogous to a .zip or .jar file and the path specifier for the compound DLL can be a classpath specifier. In another view, a compound DLL is treated as an alternative directory.
For example, assume that the compound DLL java.jll is viewed as an alternate directory called java. Both the real file system directory and the alternative directory are searched in a well-defined manner. The class loading mechanism allows DLLs to be constructed and placed in such a manner that the classpath setting requires little or no change when transitioning to a compiled environment. There are also other class loading mechanisms that allow for flexible organization and placement of compound DLLs with minimal or no modification of the classpath setting.
The classpath setting is determined from the values of the classpath run-time option and the CLASSPATH environment variable. Directories specified in the classpath setting are searched for classes contained within appropriately named compound DLLs (.jll) and simple DLLs (.jlc). You can also include path specifiers for compound DLLs in the classpath setting. These DLLs will also be searched for compiled classes. This is similar to including .zip or .jar files in the classpath setting. Any .zip or .jar file specifiers in the classpath setting are also treated in a special fashion when a search is conducted for compiled classes.
Additional information about running applications is found in the topic Running Executables and DLLs. Additional information about setting the classpath is found in the topic Loading Classes with the Classpath Setting.
Building Executables and DLLs
Loading Classes with the Classpath
Setting
Running Executables and DLLs