There seems vague statements related to exception handking in JNI.
SUN should clarify which functions can be called even if an exception
is pending in JNI calls.
---
The java JNI web page says,
(http://java.sun.com/j2se/1.4.2/docs/guide/jni/spec/design.html#wp17626)
"...After an exception has been raised, the native code must first
clear the exception before making other JNI calls. When there is a
pending exception, the only JNI functions that are safe to call are
ExceptionOccurred(), ExceptionDescribe(), and ExceptionClear(). The
ExceptionDescribe() function prints a debugging message about the
pending exception. ..."
According to the statement, we can only call
ExceptionOccurred()
ExceptionDescribe()
ExceptionClear()
when there is a pending exception.
however, we found the folllowing part in
./j2se/src/share/native/java/io/ObjectStreamClass.c
-->
...
JNIEXPORT jboolean JNICALL
Java_java_io_ObjectStreamClass_hasStaticInitializer(JNIEnv *env,
jclass this,
jclass clazz)
{
jclass superCl = NULL;
jmethodID superClinitId = NULL;
jmethodID clinitId =
(*env)->GetStaticMethodID(env, clazz, "", "()V");
if (clinitId == NULL) { /* error thrown */
jthrowable th = (*env)->ExceptionOccurred(env);
if ((*env)->IsInstanceOf(env, th, noSuchMethodErrCl)) { <=== (*)
(*env)->ExceptionClear(env); /* normal return */
}
return JNI_FALSE;
}
...
<--
Although the web statement says any JNI call should not be called
before ExceptionClear(), IsInstanceOf() is called.(above (*))
===========================================================
SUN should clarify which functions can be called even if an exception
is pending in JNI calls.
---
The java JNI web page says,
(http://java.sun.com/j2se/1.4.2/docs/guide/jni/spec/design.html#wp17626)
"...After an exception has been raised, the native code must first
clear the exception before making other JNI calls. When there is a
pending exception, the only JNI functions that are safe to call are
ExceptionOccurred(), ExceptionDescribe(), and ExceptionClear(). The
ExceptionDescribe() function prints a debugging message about the
pending exception. ..."
According to the statement, we can only call
ExceptionOccurred()
ExceptionDescribe()
ExceptionClear()
when there is a pending exception.
however, we found the folllowing part in
./j2se/src/share/native/java/io/ObjectStreamClass.c
-->
...
JNIEXPORT jboolean JNICALL
Java_java_io_ObjectStreamClass_hasStaticInitializer(JNIEnv *env,
jclass this,
jclass clazz)
{
jclass superCl = NULL;
jmethodID superClinitId = NULL;
jmethodID clinitId =
(*env)->GetStaticMethodID(env, clazz, "", "()V");
if (clinitId == NULL) { /* error thrown */
jthrowable th = (*env)->ExceptionOccurred(env);
if ((*env)->IsInstanceOf(env, th, noSuchMethodErrCl)) { <=== (*)
(*env)->ExceptionClear(env); /* normal return */
}
return JNI_FALSE;
}
...
<--
Although the web statement says any JNI call should not be called
before ExceptionClear(), IsInstanceOf() is called.(above (*))
===========================================================
- duplicates
-
JDK-6364623 JNI specification may need to be corrected.
-
- Closed
-
- relates to
-
JDK-6369169 PopLocalFrame() should be safe to use when an exception is pending
-
- Closed
-