From 5d82b481f10e3d68ef4b318fd06522fa44ca0973 Mon Sep 17 00:00:00 2001 From: Robert Toyonaga Date: Fri, 7 Nov 2025 10:08:01 -0500 Subject: [PATCH 1/2] substitute JFR method tracing and timing classes --- ...k_jfr_internal_settings_MethodSetting.java | 40 +++++++++++++++++++ ...k_jfr_internal_tracing_PlatformTracer.java | 35 ++++++++++++++++ .../svm/core/jfr/logging/JfrLogging.java | 7 ++++ 3 files changed, 82 insertions(+) create mode 100644 substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_settings_MethodSetting.java create mode 100644 substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_tracing_PlatformTracer.java diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_settings_MethodSetting.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_settings_MethodSetting.java new file mode 100644 index 000000000000..30dce6ead1f6 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_settings_MethodSetting.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2025, IBM Inc. 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.oracle.svm.core.jfr; + +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; +import jdk.jfr.internal.PlatformEventType; +import java.util.List; + +@TargetClass(className = "jdk.jfr.internal.settings.MethodSetting") +public final class Target_jdk_jfr_internal_settings_MethodSetting { + @Substitute + protected void apply(PlatformEventType eventType, List filters) { + SubstrateJVM.getLogging().logJfrSettingWarning("Method timing and tracing is not supported yet."); + } +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_tracing_PlatformTracer.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_tracing_PlatformTracer.java new file mode 100644 index 000000000000..86378bcf62b5 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_tracing_PlatformTracer.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2025, IBM Inc. 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.oracle.svm.core.jfr; + +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; + +@TargetClass(className = "jdk.jfr.internal.tracing.PlatformTracer") +@Substitute +public final class Target_jdk_jfr_internal_tracing_PlatformTracer { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/logging/JfrLogging.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/logging/JfrLogging.java index 2ce716570fc1..fbbae6b04f01 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/logging/JfrLogging.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/logging/JfrLogging.java @@ -67,6 +67,13 @@ public void warnInternal(String message) { log(tagSetId, JfrLogConfiguration.JfrLogLevel.WARNING.level, message); } + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "May be used during OOME emergency dump.") + public void logJfrSettingWarning(String message) { + int tagSetId = SubstrateUtil.cast(LogTag.JFR_SETTING, Target_jdk_jfr_internal_LogTag.class).id; + log(tagSetId, JfrLogConfiguration.JfrLogLevel.WARNING.level, message); + + } + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "May be used during OOME emergency dump.") public void log(int tagSetId, int level, String message) { if (message == null) { From 9d8c720090b047d26de164b73764f61084c5e183 Mon Sep 17 00:00:00 2001 From: Robert Toyonaga Date: Fri, 7 Nov 2025 10:46:43 -0500 Subject: [PATCH 2/2] suppress warning unused --- .../core/jfr/Target_jdk_jfr_internal_settings_MethodSetting.java | 1 + 1 file changed, 1 insertion(+) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_settings_MethodSetting.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_settings_MethodSetting.java index 30dce6ead1f6..dee2e389bb83 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_settings_MethodSetting.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_settings_MethodSetting.java @@ -31,6 +31,7 @@ import jdk.jfr.internal.PlatformEventType; import java.util.List; +@SuppressWarnings({"unused", "static-method"}) // @TargetClass(className = "jdk.jfr.internal.settings.MethodSetting") public final class Target_jdk_jfr_internal_settings_MethodSetting { @Substitute