E
Elaine Cheong
Does anyone know how to display BOTH the C code line number and the Java
exception type in a JNI exception stack trace in Java? Printing to stdout
or stderr in C is not sufficient, since I need to display the information
in a Java GUI dialog box.
Example:
In my C code, I call JNI GetMethodID() to get a reference to a Java method
that doesn't exist. NoSuchMethodError exception is thrown. I am able to
do one of the following:
a. In the C code, check for the exception, and return immediately to the
Java code, where it catches the NoSuchMethodError Throwable object and
displays the stack trace, which only indicates the Java code line numbers
and type of the Throwable object. It does not indicate the C code line
number(s).
b. In the C code, check for the exception, print out the stack trace
using ExceptionDescribe(), clear the exception using ExceptionClear(), and
then creating and throwing my own Throwable object that contains the C
code line number (using __LINE__) in the error message back to the Java
code. Is it possible to get the original Throwable object type and error
message saved into a C data structure w/o crashing the JVM due to calling
disallowed JNI functions? Otherwise, the Java code does not know which
one of the following exceptions was thrown:
- NoSuchMethodError: if the specified method cannot be found.
- ExceptionInInitializerError: if the class initializer fails due to an
exception.
- OutOfMemoryError: if the system runs out of memory.
If you post to the newsgroup, please also reply to me by email.
Thanks,
Elaine
exception type in a JNI exception stack trace in Java? Printing to stdout
or stderr in C is not sufficient, since I need to display the information
in a Java GUI dialog box.
Example:
In my C code, I call JNI GetMethodID() to get a reference to a Java method
that doesn't exist. NoSuchMethodError exception is thrown. I am able to
do one of the following:
a. In the C code, check for the exception, and return immediately to the
Java code, where it catches the NoSuchMethodError Throwable object and
displays the stack trace, which only indicates the Java code line numbers
and type of the Throwable object. It does not indicate the C code line
number(s).
b. In the C code, check for the exception, print out the stack trace
using ExceptionDescribe(), clear the exception using ExceptionClear(), and
then creating and throwing my own Throwable object that contains the C
code line number (using __LINE__) in the error message back to the Java
code. Is it possible to get the original Throwable object type and error
message saved into a C data structure w/o crashing the JVM due to calling
disallowed JNI functions? Otherwise, the Java code does not know which
one of the following exceptions was thrown:
- NoSuchMethodError: if the specified method cannot be found.
- ExceptionInInitializerError: if the class initializer fails due to an
exception.
- OutOfMemoryError: if the system runs out of memory.
If you post to the newsgroup, please also reply to me by email.
Thanks,
Elaine