Rational Developer for System z
Enterprise COBOL for z/OS バージョン 4.1 プログラミング・ガイド


例: Java int 配列の処理

次の例は、Java 配列クラスと JNI サービスを使用した、COBOL での Java 配列の処理を示しています。

 cbl lib,thread,dll 
 Identification division. 
 Class-id. OOARRAY inherits Base.
 Environment division.
 Configuration section. 
 Repository.
     Class Base is "java.lang.Object"
     Class jintArray is "jintArray".
 Identification division. 
 Object. 
 Procedure division. 
   Identification division.
   Method-id. "ProcessArray".
   Data Division.
   Local-storage section.
   01 intArrayPtr pointer.
   01 intArrayLen pic S9(9) comp-5.
   Linkage section.
      COPY JNI.
   01 inIntArrayObj usage object reference jintArray.
   01 intArrayGroup.
      02 X pic S9(9) comp-5
          occurs 1 to 1000 times depending on intArrayLen.
   Procedure division using by value inIntArrayObj.
       Set address of JNIEnv to JNIEnvPtr
       Set address of JNINativeInterface to JNIEnv
 
       Call GetArrayLength
         using by value JNIEnvPtr inIntArrayObj 
         returning intArrayLen
       Call GetIntArrayElements
         using by value JNIEnvPtr inIntArrayObj 0
         returning IntArrayPtr
       Set address of intArrayGroup to intArrayPtr
 
*  . . . process the array elements X(I) . . .
 
       Call ReleaseIntArrayElements
         using by value JNIEnvPtr inIntArrayObj intArrayPtr 0.
   End method "ProcessArray".
 End Object. 
 End class OOARRAY.

ご利用条件 | フィードバック

このインフォメーション・センターでは Eclipse テクノロジーが採用されています。(http://www.eclipse.org)