Skip to content


Browse files Browse the repository at this point in the history
8290839: jdk/jfr/event/compiler/ failed with "Runt…
…imeException: No JIT restart event found: expected true, was false"

Backport-of: 5d1ad3968416f2d1740453825445a0deb295f5de
  • Loading branch information
MBaesken committed Nov 18, 2022
1 parent 52103da commit 1c13d7e
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions test/jdk/jdk/jfr/event/compiler/
Expand Up @@ -24,6 +24,7 @@
package jdk.jfr.event.compiler;

import java.util.List;
import java.util.Comparator;

import jdk.jfr.Recording;
import jdk.jfr.consumer.RecordedEvent;
Expand All @@ -50,22 +51,23 @@
public class TestJitRestart {

public static void main(String[] args) throws Exception {
boolean foundJitRestart = false;
boolean checkJitRestartCompilation = false;
for (BlobType btype : BlobType.getAvailable()) {
boolean jr = testWithBlobType(btype, calculateAvailableSize(btype));
if (jr) {
System.out.println("JIT restart event found for BlobType " + btype);
foundJitRestart = true;
System.out.println("JIT restart event / Compilation event check for BlobType " + btype + " was successful");
checkJitRestartCompilation = true;
Asserts.assertTrue(foundJitRestart, "No JIT restart event found");
Asserts.assertTrue(checkJitRestartCompilation, "No JIT restart event found and unexpected compilation seen");

private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();

private static boolean testWithBlobType(BlobType btype, long availableSize) throws Exception {
Recording r = new Recording();
long addr = WHITE_BOX.allocateCodeBlob(availableSize,;
Expand All @@ -74,18 +76,34 @@ private static boolean testWithBlobType(BlobType btype, long availableSize) thro

List<RecordedEvent> events = Events.fromRecording(r);
System.out.println("# events:" + events.size());

boolean compilationCanHappen = true;
for (RecordedEvent evt: events) {
if (evt.getEventType().getName().equals("jdk.CodeCacheFull")) {
System.out.println("--> jdk.CodeCacheFull found");
compilationCanHappen = false;
if (evt.getEventType().getName().equals("jdk.Compilation") && !compilationCanHappen) {
return false;
if (evt.getEventType().getName().equals("jdk.JITRestart")) {
System.out.println("--> jdk.JitRestart found");
Events.assertField(evt, "codeCacheMaxCapacity").notEqual(0L);
Events.assertField(evt, "freedMemory").notEqual(0L);
System.out.println("JIT restart event found for BlobType " + btype);
return true;
return false;

// in some seldom cases we do not see the JitRestart event; but then
// do not fail (as long as no compilation happened before)
return true;

// Compute the available size for this BlobType by taking into account
Expand Down

1 comment on commit 1c13d7e

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.