Skip to content

Commit 7bc1551

Browse files
[GR-71287] Reduce image size when using JFR.
PullRequest: graal/22588
2 parents eb1d4f4 + f1f1117 commit 7bc1551

File tree

4 files changed

+93
-0
lines changed

4 files changed

+93
-0
lines changed

substratevm/mx.substratevm/suite.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,8 @@
383383
"jdk.jfr.internal",
384384
"jdk.jfr.internal.event",
385385
"jdk.jfr.internal.jfc",
386+
"jdk.jfr.internal.settings",
387+
"jdk.jfr.internal.tracing",
386388
],
387389
"jdk.internal.vm.ci": [
388390
"jdk.vm.ci.meta",
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2025, 2025, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2025, 2025, IBM Inc. All rights reserved.
4+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5+
*
6+
* This code is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU General Public License version 2 only, as
8+
* published by the Free Software Foundation. Oracle designates this
9+
* particular file as subject to the "Classpath" exception as provided
10+
* by Oracle in the LICENSE file that accompanied this code.
11+
*
12+
* This code is distributed in the hope that it will be useful, but WITHOUT
13+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15+
* version 2 for more details (a copy is included in the LICENSE file that
16+
* accompanied this code).
17+
*
18+
* You should have received a copy of the GNU General Public License version
19+
* 2 along with this work; if not, write to the Free Software Foundation,
20+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21+
*
22+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23+
* or visit www.oracle.com if you need additional information or have any
24+
* questions.
25+
*/
26+
27+
package com.oracle.svm.core.jfr;
28+
29+
import java.util.List;
30+
31+
import com.oracle.svm.core.annotate.Substitute;
32+
import com.oracle.svm.core.annotate.TargetClass;
33+
34+
import jdk.jfr.internal.PlatformEventType;
35+
import jdk.jfr.internal.settings.MethodSetting;
36+
37+
@SuppressWarnings({"unused", "static-method"}) //
38+
@TargetClass(value = MethodSetting.class)
39+
public final class Target_jdk_jfr_internal_settings_MethodSetting {
40+
@Substitute
41+
private void apply(PlatformEventType eventType, List<String> filters) {
42+
SubstrateJVM.getLogging().logJfrSettingWarning("Method timing and tracing is not supported yet.");
43+
}
44+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (c) 2025, 2025, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2025, 2025, IBM Inc. All rights reserved.
4+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5+
*
6+
* This code is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU General Public License version 2 only, as
8+
* published by the Free Software Foundation. Oracle designates this
9+
* particular file as subject to the "Classpath" exception as provided
10+
* by Oracle in the LICENSE file that accompanied this code.
11+
*
12+
* This code is distributed in the hope that it will be useful, but WITHOUT
13+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15+
* version 2 for more details (a copy is included in the LICENSE file that
16+
* accompanied this code).
17+
*
18+
* You should have received a copy of the GNU General Public License version
19+
* 2 along with this work; if not, write to the Free Software Foundation,
20+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21+
*
22+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23+
* or visit www.oracle.com if you need additional information or have any
24+
* questions.
25+
*/
26+
27+
package com.oracle.svm.core.jfr;
28+
29+
import com.oracle.svm.core.annotate.Substitute;
30+
import com.oracle.svm.core.annotate.TargetClass;
31+
32+
import jdk.jfr.internal.tracing.PlatformTracer;
33+
34+
/**
35+
* This class is not supported at the moment. So, we completely replace it with an empty
36+
* implementation to reduce the image size.
37+
*/
38+
@Substitute
39+
@TargetClass(value = PlatformTracer.class)
40+
public final class Target_jdk_jfr_internal_tracing_PlatformTracer {
41+
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/logging/JfrLogging.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ public void warnInternal(String message) {
6767
log(tagSetId, JfrLogConfiguration.JfrLogLevel.WARNING.level, message);
6868
}
6969

70+
@RestrictHeapAccess(access = NO_ALLOCATION, reason = "May be used during OOME emergency dump.")
71+
public void logJfrSettingWarning(String message) {
72+
int tagSetId = SubstrateUtil.cast(LogTag.JFR_SETTING, Target_jdk_jfr_internal_LogTag.class).id;
73+
log(tagSetId, JfrLogConfiguration.JfrLogLevel.WARNING.level, message);
74+
}
75+
7076
@RestrictHeapAccess(access = NO_ALLOCATION, reason = "May be used during OOME emergency dump.")
7177
public void log(int tagSetId, int level, String message) {
7278
if (message == null) {

0 commit comments

Comments
 (0)