Skip to content

Commit 6b9df03

Browse files
quadhieralbertnetymk
authored andcommitted
8311240: Eliminate usage of testcases.jar from TestMetaSpaceLog.java
Reviewed-by: ayang, tschatzl
1 parent 3e1b1bf commit 6b9df03

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

test/hotspot/jtreg/gc/logging/TestMetaSpaceLog.java

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
import java.util.regex.Matcher;
3232

3333
import jdk.test.lib.Asserts;
34+
import jdk.test.lib.ByteCodeLoader;
35+
import jdk.test.lib.compiler.InMemoryJavaCompiler;
3436
import jdk.test.lib.process.OutputAnalyzer;
3537
import jdk.test.lib.process.ProcessTools;
3638
import jdk.test.whitebox.WhiteBox;
@@ -91,9 +93,6 @@ private static boolean check(String line) {
9193
}
9294

9395
private static void testMetaSpaceUpdate() throws Exception {
94-
// Propagate test.src for the jar file.
95-
String testSrc= "-Dtest.src=" + System.getProperty("test.src", ".");
96-
9796
ProcessBuilder pb =
9897
ProcessTools.createTestJvm(
9998
"-Xlog:gc*",
@@ -102,7 +101,7 @@ private static void testMetaSpaceUpdate() throws Exception {
102101
"-XX:+WhiteBoxAPI",
103102
"-Xmx1000M",
104103
"-Xms1000M",
105-
testSrc, StressMetaSpace.class.getName());
104+
StressMetaSpace.class.getName());
106105

107106
OutputAnalyzer output = null;
108107
try {
@@ -117,29 +116,20 @@ private static void testMetaSpaceUpdate() throws Exception {
117116
}
118117

119118
static class StressMetaSpace {
120-
private static URL[] urls = new URL[1];
121-
122-
static {
123-
try {
124-
File jarFile = new File(System.getProperty("test.src") + "/testcases.jar");
125-
urls[0] = jarFile.toURI().toURL();
126-
} catch (Exception e) {
127-
e.printStackTrace();
128-
}
129-
}
130119

131120
public static void main(String args[]) {
132-
WhiteBox wb = WhiteBox.getWhiteBox();
133-
for(int i = 0; i < 10000; i++) {
134-
loadClass(wb);
135-
}
136-
wb.fullGC();
121+
loadManyClasses();
122+
WhiteBox.getWhiteBox().fullGC();
137123
}
138124

139-
public static void loadClass(WhiteBox wb) {
125+
public static void loadManyClasses() {
126+
String className = "Tmp";
127+
String sourceCode = "public class Tmp {}";
128+
byte[] byteCode = InMemoryJavaCompiler.compile(className, sourceCode);
140129
try {
141-
URLClassLoader ucl = new URLClassLoader(urls);
142-
Class.forName("case00", false, ucl);
130+
for (int i = 0; i < 10000; i++) {
131+
ByteCodeLoader.load(className, byteCode);
132+
}
143133
} catch (Exception e) {
144134
e.printStackTrace();
145135
}
-17.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)