8291524: jdk/jfr/event/runtime/TestClassLoaderStatsEvent.java Value not equal to 2, field='hiddenClassCount', value='0'

Reviewed-by: hseigel
This commit is contained in:
Erik Gahlin 2022-08-02 14:41:38 +00:00
parent 1d16c91ba7
commit 54c093ab0e
2 changed files with 10 additions and 6 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2022, 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
@ -56,9 +56,11 @@ public class TestClassLoaderStatsEvent {
private final static String CLASS_LOADER_NAME = "MyDummyClassLoader";
private final static String CLASSLOADER_TYPE_NAME = "jdk.jfr.event.runtime.TestClassLoaderStatsEvent$DummyClassLoader";
public static DummyClassLoader dummyloader;
public static Class<?>[] classes;
public static void main(String[] args) throws Throwable {
createDummyClassLoader(CLASS_LOADER_NAME);
System.gc();
Recording recording = new Recording();
recording.enable(EVENT_NAME);
@ -106,7 +108,7 @@ public class TestClassLoaderStatsEvent {
Method m = c.getDeclaredMethod("createNonFindableClasses", byte[].class);
m.setAccessible(true);
m.invoke(null, klassbuf);
classes = (Class[]) m.invoke(null, klassbuf);
}
public static class DummyClassLoader extends ClassLoader {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2022, 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
@ -85,10 +85,12 @@ class TestClass {
r.run();
}
public static void createNonFindableClasses(byte[] klassbuf) throws Throwable {
public static Class<?>[] createNonFindableClasses(byte[] klassbuf) throws Throwable {
// Create a hidden class and an array of hidden classes.
Lookup lookup = MethodHandles.lookup();
Class<?> clh = lookup.defineHiddenClass(klassbuf, false, NESTMATE).lookupClass();
Class<?> arrayOfHidden = Array.newInstance(clh, 10).getClass(); // HAS ISSUES?
Class<?>[] classes = new Class[2];
classes[0] = lookup.defineHiddenClass(klassbuf, false, NESTMATE).lookupClass();
classes[1] = Array.newInstance(classes[0], 10).getClass(); // HAS ISSUES?
return classes;
}
}