8258734: jdk/jfr/event/oldobject/TestClassLoaderLeak.java failed with "RuntimeException: Could not find class leak"

Reviewed-by: mgronlun
This commit is contained in:
Erik Gahlin 2021-09-22 11:45:29 +00:00
parent d245a8cc85
commit aefd4ac4a3

View File

@ -56,11 +56,14 @@ public class TestClassLoaderLeak {
r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity");
r.start();
TestClassLoader testClassLoader = new TestClassLoader();
for (Class<?> clazz : testClassLoader.loadClasses(OldObjects.MIN_SIZE / 20)) {
for (Class<?> clazz : testClassLoader.loadClasses(OldObjects.MIN_SIZE / 200)) {
// Allocate array to trigger sampling code path for interpreter / c1
for (int i = 0; i < 20; i++) {
for (int i = 0; i < 200; i++) {
Object classArray = Array.newInstance(clazz, 20);
Array.set(classArray, i, clazz.newInstance());
// No need to fill whole array
for (int j = 0; j < 5; j++) {
Array.set(classArray, j, clazz.getConstructors()[0].newInstance());
}
classObjects.add(classArray);
}
}
@ -68,6 +71,7 @@ public class TestClassLoaderLeak {
List<RecordedEvent> events = Events.fromRecording(r);
Events.hasEvents(events);
for (RecordedEvent e : events) {
System.out.println(e);
RecordedObject object = e.getValue("object");
RecordedClass rc = object.getValue("type");
if (rc.getName().contains("TestClass")) {