From cb9deb82a223f462397e46dba65bcb89ff865b43 Mon Sep 17 00:00:00 2001 From: Robert Toyonaga Date: Fri, 7 Nov 2025 10:08:01 -0500 Subject: [PATCH 1/3] substitute JFR method tracing and timing classes (cherry picked from commit 5d82b481f10e3d68ef4b318fd06522fa44ca0973) --- ...k_jfr_internal_settings_MethodSetting.java | 40 +++++++++++++++++++ ...k_jfr_internal_tracing_PlatformTracer.java | 35 ++++++++++++++++ .../svm/core/jfr/logging/JfrLogging.java | 6 +++ 3 files changed, 81 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 f4243c721b2f..fefc80b2f921 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 @@ -59,6 +59,12 @@ public void warnInternal(String message) { log(tagSetId, JfrLogConfiguration.JfrLogLevel.WARNING.level, message); } + 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); + + } + public void log(int tagSetId, int level, String message) { if (message == null) { return; From b759080cfc72f6c6b364ff5a76358e604747cade Mon Sep 17 00:00:00 2001 From: Robert Toyonaga Date: Fri, 7 Nov 2025 10:46:43 -0500 Subject: [PATCH 2/3] suppress warning unused (cherry picked from commit 9d8c720090b047d26de164b73764f61084c5e183) --- .../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 From ed85c8c108ec83e9b3ff650fcc04eb226bda4595 Mon Sep 17 00:00:00 2001 From: Christian Haeubl Date: Mon, 10 Nov 2025 10:36:04 +0100 Subject: [PATCH 3/3] Cleanups. (cherry picked from commit f1f111714f2ffca0e4cd6ea2eead0b4b4a6926d1) --- substratevm/mx.substratevm/suite.py | 2 ++ .../Target_jdk_jfr_internal_settings_MethodSetting.java | 9 ++++++--- .../Target_jdk_jfr_internal_tracing_PlatformTracer.java | 8 +++++++- .../src/com/oracle/svm/core/jfr/logging/JfrLogging.java | 1 - 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/substratevm/mx.substratevm/suite.py b/substratevm/mx.substratevm/suite.py index 3b1c529aec97..2d6102db8f74 100644 --- a/substratevm/mx.substratevm/suite.py +++ b/substratevm/mx.substratevm/suite.py @@ -400,6 +400,8 @@ "jdk.jfr.internal", "jdk.jfr.internal.event", "jdk.jfr.internal.jfc", + "jdk.jfr.internal.settings", + "jdk.jfr.internal.tracing", ], "jdk.internal.vm.ci": [ "jdk.vm.ci.meta", 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 dee2e389bb83..63475a50d984 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 @@ -26,16 +26,19 @@ package com.oracle.svm.core.jfr; +import java.util.List; + import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; + import jdk.jfr.internal.PlatformEventType; -import java.util.List; +import jdk.jfr.internal.settings.MethodSetting; @SuppressWarnings({"unused", "static-method"}) // -@TargetClass(className = "jdk.jfr.internal.settings.MethodSetting") +@TargetClass(value = MethodSetting.class) public final class Target_jdk_jfr_internal_settings_MethodSetting { @Substitute - protected void apply(PlatformEventType eventType, List filters) { + private 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 index 86378bcf62b5..9d7642274230 100644 --- 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 @@ -29,7 +29,13 @@ import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -@TargetClass(className = "jdk.jfr.internal.tracing.PlatformTracer") +import jdk.jfr.internal.tracing.PlatformTracer; + +/** + * This class is not supported at the moment. So, we completely replace it with an empty + * implementation to reduce the image size. + */ @Substitute +@TargetClass(value = PlatformTracer.class) 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 fefc80b2f921..dfc67a75e03d 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 @@ -62,7 +62,6 @@ public void warnInternal(String message) { 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); - } public void log(int tagSetId, int level, String message) {