On Tue, 14 Apr 2026 19:09:37 GMT, Serguei Spitsyn <[email protected]> wrote:

> > If this code returns to Java (I can't tell easily) then we should not clear 
> > the exception.
> 
> It is in the `ClassFileLoadHook` callback (posting a CFLH event), so this 
> code should eventually return to Java. Was the original error reported by 
> `-Xcheck:jni` that the exception has not been cleared?
> 
> Update: This is an assert:
> 
> ```
>  # assert(!_thread->is_pending_jni_exception_check()) failed: Pending JNI 
> Exception Check
> 
> class ThreadToNativeFromVM : public ThreadStateTransition {
>  public:
>   ThreadToNativeFromVM(JavaThread *thread) : ThreadStateTransition(thread) {
>     assert(!thread->owns_locks(), "must release all locks when leaving VM");
>     transition_from_vm(thread, _thread_in_native);
>   }
>   ~ThreadToNativeFromVM() {
>     transition_from_native(_thread, _thread_in_vm);
>     assert(!_thread->is_pending_jni_exception_check(), "Pending JNI Exception 
> Check");  **<== HERE!!!**
>     // We don't need to clear_walkable because it will happen automagically 
> when we return to java
>   }
> };
> ```
> 
> So, the transition is from native to VM first. It is where we do not except 
> pending exceptions with `-Xcheck:jni`. So, we probably should use 
> `ExceptionDescribe` as you suggested.

Added ExceptionDescribe before ExceptionClear after CallObjectMethod. Also 
wrapped CallStaticVoidMethod with NSK_JNI_VERIFY_VOID

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/30711#discussion_r3083700389

Reply via email to