--- old/src/hotspot/share/jfr/metadata/metadata.xml 2020-02-26 11:26:17.535970000 +0100
+++ new/src/hotspot/share/jfr/metadata/metadata.xml 2020-02-26 11:26:16.425449100 +0100
@@ -274,6 +274,9 @@
+
+
+
--- old/src/hotspot/share/prims/jvm.cpp 2020-02-26 11:26:24.760501800 +0100
+++ new/src/hotspot/share/prims/jvm.cpp 2020-02-26 11:26:23.541198500 +0100
@@ -486,6 +486,8 @@
JVM_ENTRY_NO_ENV(void, JVM_GC(void))
JVMWrapper("JVM_GC");
if (!DisableExplicitGC) {
+ EventSystemGC event;
+ event.commit();
Universe::heap()->collect(GCCause::_java_lang_system_gc);
}
JVM_END
--- old/src/jdk.jfr/share/conf/jfr/default.jfc 2020-02-26 11:26:31.905488100 +0100
+++ new/src/jdk.jfr/share/conf/jfr/default.jfc 2020-02-26 11:26:30.791874900 +0100
@@ -341,6 +341,11 @@
0 ms
+
+ true
+ true
+
+
true
0 ms
--- old/src/jdk.jfr/share/conf/jfr/profile.jfc 2020-02-26 11:26:38.915622200 +0100
+++ new/src/jdk.jfr/share/conf/jfr/profile.jfc 2020-02-26 11:26:37.806285100 +0100
@@ -340,6 +340,11 @@
true
0 ms
+
+
+ true
+ true
+
true
--- old/test/lib/jdk/test/lib/jfr/EventNames.java 2020-02-26 11:26:45.816006600 +0100
+++ new/test/lib/jdk/test/lib/jfr/EventNames.java 2020-02-26 11:26:44.646675600 +0100
@@ -141,6 +141,7 @@
public final static String AllocationRequiringGC = PREFIX + "AllocationRequiringGC";
public final static String GCPhaseParallel = PREFIX + "GCPhaseParallel";
public final static String GCPhaseConcurrent = PREFIX + "GCPhaseConcurrent";
+ public static final String SystemGC = PREFIX + "SystemGC";
// Compiler
public final static String Compilation = PREFIX + "Compilation";
--- /dev/null 2020-02-26 11:26:53.000000000 +0100
+++ new/test/jdk/jdk/jfr/event/gc/collection/TestSystemGc.java 2020-02-26 11:26:51.426623000 +0100
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2020, 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
+ * 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 jdk.jfr.event.gc.collection;
+
+import java.lang.management.ManagementFactory;
+import java.util.List;
+
+import jdk.jfr.Recording;
+import jdk.jfr.consumer.RecordedEvent;
+import jdk.test.lib.Asserts;
+import jdk.test.lib.jfr.EventNames;
+import jdk.test.lib.jfr.Events;
+
+/**
+ * @test
+ * @key jfr
+ * @requires vm.hasJFR
+ * @library /test/lib /test/jdk
+ * @run main/othervm jdk.jfr.event.gc.collection.TestSystemGC
+ */
+public class TestSystemGC {
+ public static void main(String[] args) throws Exception {
+ try (Recording recording = new Recording()) {
+ recording.enable(EventNames.SystemGC);
+ recording.start();
+
+ // Trigger 3 System GC
+ System.gc();
+ ManagementFactory.getMemoryMXBean().gc();
+ Runtime.getRuntime().gc();
+
+ recording.stop();
+ List events = Events.fromRecording(recording);
+ System.out.println(events);
+
+ Asserts.assertEquals(3, events.size(), "Expected 3 SystemGC events");
+
+ RecordedEvent event1 = events.get(0);
+ Events.assertFrame(event1, System.class, "gc");
+ Events.assertEventThread(event1, Thread.currentThread());
+
+ RecordedEvent event2 = events.get(1);
+ Events.assertFrame(event2, Runtime.class, "gc");
+ Events.assertEventThread(event2, Thread.currentThread());
+
+ RecordedEvent event3 = events.get(2);
+ // MemoryMXBean.class is an interface so can't assertFrame on it
+ Events.assertEventThread(event3, Thread.currentThread());
+ }
+ }
+}