Rational Developer for System z
PL/I for Windows, Version 7.6, Programming Guide

Step 3: Writing the PL/I Program

The PL/I implementation of the native method looks much like any other PL/I subroutine.

Useful PL/I Compiler Options

The sample program contains a series of *PROCESS statements that define the important compiler options.

 *Process Limits( Extname( 31 ) ) Margins( 1, 100 ) ;
 *Process Dllinit xinfo(def);
 *Process Default( IEEE );

Here is a brief description of them and why they are useful:

Extname(31)
Allows for longer, Java style, external names.
Margins(1,100)
Extending the margins gives you more room for Java style names and identifiers.
Dllinit
Includes the initilization coded needed for creating a DLL.
xinfo(def)
Instructs the compiler to build a *.DEF file to be used in the creation of the DLL.
Default( IEEE );
IEEE specifies that FLOAT data is held in IEEE format - the form in which it is held by JAVA

Correct Form of PL/I Procedure Name and Procedure Statement

The PL/I procedure name must conform to the Java naming convention in order to be located by the Java Class Loader at execution time. The Java naming scheme consists of three parts. The first part identifies the routine to the Java environment, the second part is the name of the Java class that defines the native method, and the third part is the name of the native method itself.

Here is a breakdown of the external PL/I procedure name _Java_callingPLI_callToPLI in the sample program:

_Java
All native methods resident in dynamic libraries must begin with _Java
_callingPLI
The name of the Java class that declares the native method
_callToPLI
The name of the native method itself.
Note:
There is an important difference between coding a native method in PL/I and in C. The javah tool, which is shipped with the JDK, generates the form of the external references required for C programs. When you write your native methods in PL/I and follow the rules above for naming your PL/I external references, performing the javah step is not necessary for PL/I native methods.

The complete procedure statement for the sample program looks like this:

  Java_callingPLI_callToPLI:
  Proc( JNIEnv , MyJObject )
    External( "_Java_callingPLI_callToPLI" )
    Options( NoDescriptor ByValue linkage(stdcall) );

JNI Include File

The PL/I include file which contains the PL/I definition of the Java interfaces is contained in two include files, jni.cop which in turn includes jni_md.cop. These include files are included with this statement:

   %include jni;

For a complete listing of the jni.cop file look in the \ibmpliw\include directory


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)