From 8378d289104a60faa0c9ee048dc299fa7ea2c06e Mon Sep 17 00:00:00 2001 From: David Holmes Date: Tue, 17 Mar 2026 20:43:22 +0000 Subject: [PATCH] 8379481: Recent JNI methods are missing DTrace probes Reviewed-by: kbarrett, iklam, jwaters --- src/hotspot/os/posix/dtrace/hotspot_jni.d | 4 +++- src/hotspot/share/prims/jni.cpp | 15 ++++++++++----- src/hotspot/share/utilities/dtrace_disabled.hpp | 16 +++++++++------- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/hotspot/os/posix/dtrace/hotspot_jni.d b/src/hotspot/os/posix/dtrace/hotspot_jni.d index c5676921b37..1937769dcb2 100644 --- a/src/hotspot/os/posix/dtrace/hotspot_jni.d +++ b/src/hotspot/os/posix/dtrace/hotspot_jni.d @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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 @@ -366,6 +366,8 @@ provider hotspot_jni { probe IsInstanceOf__return(uintptr_t); probe IsSameObject__entry(void*, void*, void*); probe IsSameObject__return(uintptr_t); + probe IsVirtualThread__entry(void*, void*); + probe IsVirtualThread__return(uintptr_t); probe MonitorEnter__entry(void*, void*); probe MonitorEnter__return(uint32_t); probe MonitorExit__entry(void*, void*); diff --git a/src/hotspot/share/prims/jni.cpp b/src/hotspot/share/prims/jni.cpp index 2297ce9b790..85207fddf29 100644 --- a/src/hotspot/share/prims/jni.cpp +++ b/src/hotspot/share/prims/jni.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2024 Red Hat, Inc. * Copyright (c) 2021, Azul Systems, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -3129,16 +3129,21 @@ JNI_END JNI_ENTRY(jobject, jni_GetModule(JNIEnv* env, jclass clazz)) - return Modules::get_module(clazz, THREAD); + HOTSPOT_JNI_GETMODULE_ENTRY(env, clazz); + jobject ret = Modules::get_module(clazz, THREAD); + HOTSPOT_JNI_GETMODULE_RETURN(ret); + return ret; JNI_END JNI_ENTRY(jboolean, jni_IsVirtualThread(JNIEnv* env, jobject obj)) + HOTSPOT_JNI_ISVIRTUALTHREAD_ENTRY(env, obj); + jboolean ret = JNI_FALSE; oop thread_obj = JNIHandles::resolve_external_guard(obj); if (thread_obj != nullptr && thread_obj->is_a(vmClasses::BaseVirtualThread_klass())) { - return JNI_TRUE; - } else { - return JNI_FALSE; + ret = JNI_TRUE; } + HOTSPOT_JNI_ISVIRTUALTHREAD_RETURN(ret); + return ret; JNI_END diff --git a/src/hotspot/share/utilities/dtrace_disabled.hpp b/src/hotspot/share/utilities/dtrace_disabled.hpp index 6cbd79326ac..99d7cbb2f75 100644 --- a/src/hotspot/share/utilities/dtrace_disabled.hpp +++ b/src/hotspot/share/utilities/dtrace_disabled.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2026, 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 @@ -683,6 +683,10 @@ #define HOTSPOT_JNI_GETMETHODID_ENTRY_ENABLED() 0 #define HOTSPOT_JNI_GETMETHODID_RETURN(arg0) #define HOTSPOT_JNI_GETMETHODID_RETURN_ENABLED() 0 +#define HOTSPOT_JNI_GETMODULE_ENTRY(arg0, arg1) +#define HOTSPOT_JNI_GETMODULE_ENTRY_ENABLED() 0 +#define HOTSPOT_JNI_GETMODULE_RETURN(arg0) +#define HOTSPOT_JNI_GETMODULE_RETURN_ENABLED() 0 #define HOTSPOT_JNI_GETOBJECTARRAYELEMENT_ENTRY(arg0, arg1, arg2) #define HOTSPOT_JNI_GETOBJECTARRAYELEMENT_ENTRY_ENABLED() 0 #define HOTSPOT_JNI_GETOBJECTARRAYELEMENT_RETURN(arg0) @@ -811,6 +815,10 @@ #define HOTSPOT_JNI_ISSAMEOBJECT_ENTRY_ENABLED() 0 #define HOTSPOT_JNI_ISSAMEOBJECT_RETURN(arg0) #define HOTSPOT_JNI_ISSAMEOBJECT_RETURN_ENABLED() 0 +#define HOTSPOT_JNI_ISVIRTUALTHREAD_ENTRY(arg0, arg1) +#define HOTSPOT_JNI_ISVIRTUALTHREAD_ENTRY_ENABLED() 0 +#define HOTSPOT_JNI_ISVIRTUALTHREAD_RETURN(arg0) +#define HOTSPOT_JNI_ISVIRTUALTHREAD_RETURN_ENABLED() 0 #define HOTSPOT_JNI_MONITORENTER_ENTRY(arg0, arg1) #define HOTSPOT_JNI_MONITORENTER_ENTRY_ENABLED() 0 #define HOTSPOT_JNI_MONITORENTER_RETURN(arg0) @@ -1080,12 +1088,6 @@ #define HOTSPOT_JNI_UNREGISTERNATIVES_RETURN(arg0) #define HOTSPOT_JNI_UNREGISTERNATIVES_RETURN_ENABLED() 0 -/* Modules */ -#define HOTSPOT_JNI_GETMODULE_ENTRY(arg0, arg1) -#define HOTSPOT_JNI_GETMODULE_ENTRY_ENABLED() 0 -#define HOTSPOT_JNI_GETMODULE_RETURN(arg0) -#define HOTSPOT_JNI_GETMODULE_RETURN_ENABLED() - #else /* !defined(DTRACE_ENABLED) */ #error This file should only be included when dtrace is not enabled #endif /* !defined(DTRACE_ENABLED) */