From 7461dfe9c652542ef4e8f8fe36ac601ebd345492 Mon Sep 17 00:00:00 2001 From: Justin Lu Date: Wed, 30 Oct 2024 21:49:26 +0000 Subject: [PATCH] 8341788: Fix ExceptionOccurred in hotspot Reviewed-by: dholmes --- src/hotspot/share/jfr/instrumentation/jfrJvmtiAgent.cpp | 4 ++-- src/hotspot/share/prims/methodHandles.cpp | 6 +++--- src/hotspot/share/prims/nativeEntryPoint.cpp | 4 ++-- src/hotspot/share/prims/unsafe.cpp | 2 +- src/hotspot/share/prims/upcallLinker.cpp | 4 ++-- src/hotspot/share/prims/upcallStubs.cpp | 4 ++-- src/hotspot/share/runtime/continuation.cpp | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/hotspot/share/jfr/instrumentation/jfrJvmtiAgent.cpp b/src/hotspot/share/jfr/instrumentation/jfrJvmtiAgent.cpp index 882d468a4a3..f8f975528cb 100644 --- a/src/hotspot/share/jfr/instrumentation/jfrJvmtiAgent.cpp +++ b/src/hotspot/share/jfr/instrumentation/jfrJvmtiAgent.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -133,7 +133,7 @@ static void log_and_throw(jvmtiError error, TRAPS) { static void check_exception_and_log(JNIEnv* env, TRAPS) { assert(env != nullptr, "invariant"); - if (env->ExceptionOccurred()) { + if (env->ExceptionCheck()) { // array index out of bound DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_native(THREAD)); ThreadInVMfromNative tvmfn(THREAD); diff --git a/src/hotspot/share/prims/methodHandles.cpp b/src/hotspot/share/prims/methodHandles.cpp index 498da559cf5..1e44ea95731 100644 --- a/src/hotspot/share/prims/methodHandles.cpp +++ b/src/hotspot/share/prims/methodHandles.cpp @@ -1464,15 +1464,15 @@ JVM_ENTRY(void, JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass MHN_class)) ThreadToNativeFromVM ttnfv(thread); int status = env->RegisterNatives(MHN_class, MHN_methods, sizeof(MHN_methods)/sizeof(JNINativeMethod)); - guarantee(status == JNI_OK && !env->ExceptionOccurred(), + guarantee(status == JNI_OK && !env->ExceptionCheck(), "register java.lang.invoke.MethodHandleNative natives"); status = env->RegisterNatives(MH_class, MH_methods, sizeof(MH_methods)/sizeof(JNINativeMethod)); - guarantee(status == JNI_OK && !env->ExceptionOccurred(), + guarantee(status == JNI_OK && !env->ExceptionCheck(), "register java.lang.invoke.MethodHandle natives"); status = env->RegisterNatives(VH_class, VH_methods, sizeof(VH_methods)/sizeof(JNINativeMethod)); - guarantee(status == JNI_OK && !env->ExceptionOccurred(), + guarantee(status == JNI_OK && !env->ExceptionCheck(), "register java.lang.invoke.VarHandle natives"); } diff --git a/src/hotspot/share/prims/nativeEntryPoint.cpp b/src/hotspot/share/prims/nativeEntryPoint.cpp index 2dbff08a7cb..81c6058c11b 100644 --- a/src/hotspot/share/prims/nativeEntryPoint.cpp +++ b/src/hotspot/share/prims/nativeEntryPoint.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -116,6 +116,6 @@ static JNINativeMethod NEP_methods[] = { JNI_ENTRY(void, JVM_RegisterNativeEntryPointMethods(JNIEnv *env, jclass NEP_class)) ThreadToNativeFromVM ttnfv(thread); int status = env->RegisterNatives(NEP_class, NEP_methods, sizeof(NEP_methods)/sizeof(JNINativeMethod)); - guarantee(status == JNI_OK && !env->ExceptionOccurred(), + guarantee(status == JNI_OK && !env->ExceptionCheck(), "register jdk.internal.foreign.abi.NativeEntryPoint natives"); JNI_END diff --git a/src/hotspot/share/prims/unsafe.cpp b/src/hotspot/share/prims/unsafe.cpp index 239ae480030..46f9bfc3ef9 100644 --- a/src/hotspot/share/prims/unsafe.cpp +++ b/src/hotspot/share/prims/unsafe.cpp @@ -669,7 +669,7 @@ static jclass Unsafe_DefineClass_impl(JNIEnv *env, jstring name, jbyteArray data } env->GetByteArrayRegion(data, offset, length, body); - if (env->ExceptionOccurred()) { + if (env->ExceptionCheck()) { goto free_body; } diff --git a/src/hotspot/share/prims/upcallLinker.cpp b/src/hotspot/share/prims/upcallLinker.cpp index 1abce57652a..7511e278c69 100644 --- a/src/hotspot/share/prims/upcallLinker.cpp +++ b/src/hotspot/share/prims/upcallLinker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -187,6 +187,6 @@ static JNINativeMethod UL_methods[] = { JNI_ENTRY(void, JVM_RegisterUpcallLinkerMethods(JNIEnv *env, jclass UL_class)) ThreadToNativeFromVM ttnfv(thread); int status = env->RegisterNatives(UL_class, UL_methods, sizeof(UL_methods)/sizeof(JNINativeMethod)); - guarantee(status == JNI_OK && !env->ExceptionOccurred(), + guarantee(status == JNI_OK && !env->ExceptionCheck(), "register jdk.internal.foreign.abi.UpcallLinker natives"); JNI_END diff --git a/src/hotspot/share/prims/upcallStubs.cpp b/src/hotspot/share/prims/upcallStubs.cpp index 19737575fcd..3c70b671c9d 100644 --- a/src/hotspot/share/prims/upcallStubs.cpp +++ b/src/hotspot/share/prims/upcallStubs.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,7 @@ static JNINativeMethod UH_methods[] = { */ JVM_LEAF(void, JVM_RegisterUpcallHandlerMethods(JNIEnv *env, jclass UH_class)) int status = env->RegisterNatives(UH_class, UH_methods, sizeof(UH_methods)/sizeof(JNINativeMethod)); - guarantee(status == JNI_OK && !env->ExceptionOccurred(), + guarantee(status == JNI_OK && !env->ExceptionCheck(), "register jdk.internal.foreign.abi.UpcallStubs natives"); JVM_END diff --git a/src/hotspot/share/runtime/continuation.cpp b/src/hotspot/share/runtime/continuation.cpp index cd55b4a9cff..fb697dd4920 100644 --- a/src/hotspot/share/runtime/continuation.cpp +++ b/src/hotspot/share/runtime/continuation.cpp @@ -428,5 +428,5 @@ void CONT_RegisterNativeMethods(JNIEnv *env, jclass cls) { ThreadToNativeFromVM trans(thread); int status = env->RegisterNatives(cls, CONT_methods, sizeof(CONT_methods)/sizeof(JNINativeMethod)); guarantee(status == JNI_OK, "register jdk.internal.vm.Continuation natives"); - guarantee(!env->ExceptionOccurred(), "register jdk.internal.vm.Continuation natives"); + guarantee(!env->ExceptionCheck(), "register jdk.internal.vm.Continuation natives"); }