Rational Developer for System z
COBOL for Windows バージョン 7.5 プログラミング・ガイド


例: Java 例外の処理

次の例は、Java からの例外を catch するための JNI サービスの使用と、 エラー分析を行うための java.lang.Throwable の PrintStackTrace メソッドの使用を示しています。

Repository.
    Class JavaException is “java.lang.Exception”.
. . .
Local-storage section.
01 ex usage object reference JavaException.
Linkage section.
COPY “JNI.cpy”.
. . .
Procedure division.
    Set address of JNIEnv to JNIEnvPtr
    Set address of JNINativeInterface to JNIEnv
    . . .
    Invoke anObj “someMethod”
    Perform ErrorCheck
. . .
ErrorCheck.
    Call ExceptionOccurred
        using by value JNIEnvPtr
        returning ex
    If ex not = null then
        Call ExceptionClear using by value JNIEnvPtr
        Display “Caught an unexpected exception”
        Invoke ex “printStackTrace”
        Stop run
    End-if

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

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