Skip to content

Commit d0a9565

Browse files
committed
Reset JDKs cgroup subsystem instances
This is needed in order to get correct memory limits detected for some code paths (one of which is JFR). Closes: #5396
1 parent 18561fb commit d0a9565

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
26+
package com.oracle.svm.core.jdk;
27+
28+
import org.graalvm.nativeimage.Platform.LINUX;
29+
import org.graalvm.nativeimage.Platforms;
30+
31+
import com.oracle.svm.core.annotate.Alias;
32+
import com.oracle.svm.core.annotate.RecomputeFieldValue;
33+
import com.oracle.svm.core.annotate.RecomputeFieldValue.Kind;
34+
import com.oracle.svm.core.annotate.TargetClass;
35+
36+
@TargetClass(className = "jdk.internal.platform.cgroupv1.CgroupV1Subsystem")
37+
@Platforms(LINUX.class)
38+
final class Target_jdk_internal_platform_cgroupv1_CgroupV1Subsystem {
39+
@Alias //
40+
@RecomputeFieldValue(kind = Kind.Reset) //
41+
private static volatile Target_jdk_internal_platform_cgroupv1_CgroupV1Subsystem INSTANCE;
42+
}
43+
44+
@TargetClass(className = "jdk.internal.platform.cgroupv2.CgroupV2Subsystem")
45+
@Platforms(LINUX.class)
46+
final class Target_jdk_internal_platform_cgroupv2_CgroupV2Subsystem {
47+
@Alias //
48+
@RecomputeFieldValue(kind = Kind.Reset) //
49+
private static volatile Target_jdk_internal_platform_cgroupv2_CgroupV2Subsystem INSTANCE;
50+
}
51+
52+
@TargetClass(className = "jdk.jfr.internal.instrument.JDKEvents")
53+
@Platforms(LINUX.class)
54+
final class Target_jdk_jfr_internal_instrument_JDKEvents {
55+
@Alias //
56+
@RecomputeFieldValue(kind = Kind.Reset) //
57+
private static Target_jdk_internal_platform_Metrics containerMetrics;
58+
}
59+
60+
// Only present in JDKs without JDK-8268398
61+
@TargetClass(className = "jdk.jfr.internal.Utils", onlyWith = JDK17OrEarlier.class)
62+
@Platforms(LINUX.class)
63+
final class Target_jdk_jfr_internal_Utils {
64+
@Alias //
65+
@RecomputeFieldValue(kind = Kind.Reset) //
66+
private static Target_jdk_internal_platform_Metrics[] metrics;
67+
}
68+
69+
@TargetClass(className = "jdk.internal.platform.Metrics")
70+
@Platforms(LINUX.class)
71+
final class Target_jdk_internal_platform_Metrics {
72+
}
73+
74+
/** Dummy class to have a class with the file's name. */
75+
public final class JDKContainerSubstitutions {
76+
}

0 commit comments

Comments
 (0)