62
62
import java .lang .management .MemoryUsage ;
63
63
import java .util .HashSet ;
64
64
65
+ import sun .hotspot .WhiteBox ;
66
+
65
67
import nsk .share .test .Stresser ;
66
68
import vm .mlvm .share .CustomClassLoaders ;
67
69
import vm .mlvm .share .Env ;
68
70
import vm .mlvm .share .MlvmTest ;
69
- import vm .mlvm .share .WhiteBoxHelper ;
70
71
import vm .share .FileUtils ;
71
72
import vm .share .options .Option ;
72
73
@@ -87,6 +88,7 @@ public class Test extends MlvmTest {
87
88
@ Option (name = "iterations" , default_value = "100000" , description = "Iterations: each iteration loads one new class" )
88
89
private int iterations = 100_000 ;
89
90
91
+ private static final WhiteBox WHITE_BOX = WhiteBox .getWhiteBox ();
90
92
private static final int GC_COUNT = 6 ;
91
93
private static final boolean TERMINATE_ON_FULL_METASPACE = false ;
92
94
@@ -133,15 +135,6 @@ private MemoryPoolMXBean getClassMetadataMemoryPoolMXBean() {
133
135
return null ;
134
136
}
135
137
136
- private MethodHandle getFullGCMethod () throws NoSuchMethodException , IllegalAccessException {
137
- try {
138
- return WhiteBoxHelper .getMethod ("fullGC" , MethodType .methodType (void .class ));
139
- } catch (NoSuchMethodException | ClassNotFoundException | InvocationTargetException e ) {
140
- Env .traceDebug (e , "No WhiteBox API. Will use System.gc() instead of WhiteBox.fullGC()" );
141
- return MethodHandles .lookup ().findStatic (System .class , "gc" , MethodType .methodType (void .class ));
142
- }
143
- }
144
-
145
138
@ Override
146
139
public boolean run () throws Throwable {
147
140
setHeapDumpAfter (heapDumpOpt );
@@ -150,8 +143,6 @@ public boolean run() throws Throwable {
150
143
final MemoryPoolMXBean classMetadataPoolMXB = getClassMetadataMemoryPoolMXBean ();
151
144
final String memPoolName = classMetadataPoolMXB == null ? "" : classMetadataPoolMXB .getName ();
152
145
153
- MethodHandle mhCollectHeap = getFullGCMethod ();
154
-
155
146
int removedEntries = 0 ;
156
147
157
148
Stresser stresser = createStresser ();
@@ -183,7 +174,7 @@ public boolean run() throws Throwable {
183
174
}
184
175
185
176
for (int i = 0 ; i < GC_COUNT ; ++i ) {
186
- mhCollectHeap . invoke ();
177
+ WHITE_BOX . fullGC ();
187
178
Thread .sleep (500 );
188
179
removedEntries += removeQueuedReferences ();
189
180
}
0 commit comments