Skip to content
This repository was archived by the owner on Sep 19, 2023. It is now read-only.

Commit 54c093a

Browse files
committed
8291524: jdk/jfr/event/runtime/TestClassLoaderStatsEvent.java Value not equal to 2, field='hiddenClassCount', value='0'
Reviewed-by: hseigel
1 parent 1d16c91 commit 54c093a

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

test/jdk/jdk/jfr/event/runtime/TestClassLoaderStatsEvent.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -56,9 +56,11 @@ public class TestClassLoaderStatsEvent {
5656
private final static String CLASS_LOADER_NAME = "MyDummyClassLoader";
5757
private final static String CLASSLOADER_TYPE_NAME = "jdk.jfr.event.runtime.TestClassLoaderStatsEvent$DummyClassLoader";
5858
public static DummyClassLoader dummyloader;
59+
public static Class<?>[] classes;
5960

6061
public static void main(String[] args) throws Throwable {
6162
createDummyClassLoader(CLASS_LOADER_NAME);
63+
System.gc();
6264

6365
Recording recording = new Recording();
6466
recording.enable(EVENT_NAME);
@@ -106,7 +108,7 @@ private static void createDummyClassLoader(String name) throws Throwable {
106108

107109
Method m = c.getDeclaredMethod("createNonFindableClasses", byte[].class);
108110
m.setAccessible(true);
109-
m.invoke(null, klassbuf);
111+
classes = (Class[]) m.invoke(null, klassbuf);
110112
}
111113

112114
public static class DummyClassLoader extends ClassLoader {

test/jdk/jdk/jfr/event/runtime/TestClasses.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -85,10 +85,12 @@ class TestClass {
8585
r.run();
8686
}
8787

88-
public static void createNonFindableClasses(byte[] klassbuf) throws Throwable {
88+
public static Class<?>[] createNonFindableClasses(byte[] klassbuf) throws Throwable {
8989
// Create a hidden class and an array of hidden classes.
9090
Lookup lookup = MethodHandles.lookup();
91-
Class<?> clh = lookup.defineHiddenClass(klassbuf, false, NESTMATE).lookupClass();
92-
Class<?> arrayOfHidden = Array.newInstance(clh, 10).getClass(); // HAS ISSUES?
91+
Class<?>[] classes = new Class[2];
92+
classes[0] = lookup.defineHiddenClass(klassbuf, false, NESTMATE).lookupClass();
93+
classes[1] = Array.newInstance(classes[0], 10).getClass(); // HAS ISSUES?
94+
return classes;
9395
}
9496
}

0 commit comments

Comments
 (0)