-
Bug
-
Resolution: Fixed
-
P3
-
1.2.1, 5.0
-
b23
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2122507 | 5.0u2 | Iris Clark | P2 | Resolved | Fixed | b06 |
There is violation to JNI rule in ClassLoader.c, in 1.4.2 and 1.5b48.
====j2se/src/share/native/java/lang/ClassLoader.c in 1.5betab48 ====
........
329
330 if ((*env)->ExceptionOccurred(env)) {
331 JNU_ThrowByNameWithLastError(env, "java/lang/UnsatisfiedLinkError",
332 "exception occurred in JNI_OnLoad");
333 JVM_UnloadLibrary(handle);
334 JNU_ReleaseStringPlatformChars(env, name, cname);
335 return;
336 }
337
......
On the URL,
http://java.sun.com/j2se/1.5.0/docs/guide/jni/spec/design.html#wp17626
we can find out the following statement.
.....
Exception Handling
There are two ways to handle an exception in native code:
* The native method can choose to return immediately, causing the exception
to be thrown in the Java code that initiated the native method call.
* The native code can clear the exception by calling ExceptionClear(),
and then execute its own exception-handling code.
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.
...
In thhe above extracted code, in site an exception occurs,
JNU_ThrowByNameWithLastError(line #331) is called without ExceptionClear.
ExceptionClear() should be done before JNU_ThrowByNameWithLastError.
================================================================================
====j2se/src/share/native/java/lang/ClassLoader.c in 1.5betab48 ====
........
329
330 if ((*env)->ExceptionOccurred(env)) {
331 JNU_ThrowByNameWithLastError(env, "java/lang/UnsatisfiedLinkError",
332 "exception occurred in JNI_OnLoad");
333 JVM_UnloadLibrary(handle);
334 JNU_ReleaseStringPlatformChars(env, name, cname);
335 return;
336 }
337
......
On the URL,
http://java.sun.com/j2se/1.5.0/docs/guide/jni/spec/design.html#wp17626
we can find out the following statement.
.....
Exception Handling
There are two ways to handle an exception in native code:
* The native method can choose to return immediately, causing the exception
to be thrown in the Java code that initiated the native method call.
* The native code can clear the exception by calling ExceptionClear(),
and then execute its own exception-handling code.
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.
...
In thhe above extracted code, in site an exception occurs,
JNU_ThrowByNameWithLastError(line #331) is called without ExceptionClear.
ExceptionClear() should be done before JNU_ThrowByNameWithLastError.
================================================================================
- backported by
-
JDK-2122507 (cl) ClassLoader.c does not clear a pending exception - JNI spec violation
- Resolved
- relates to
-
JDK-6213473 JCK1.5: JNI call made with exception when -Xcheck:jni is used.
- Closed