8311240: Eliminate usage of testcases.jar from TestMetaSpaceLog.java
Reviewed-by: ayang, tschatzl
This commit is contained in:
parent
3e1b1bf94e
commit
6b9df037e4
@ -31,6 +31,8 @@ import java.util.regex.Pattern;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
import jdk.test.lib.Asserts;
|
import jdk.test.lib.Asserts;
|
||||||
|
import jdk.test.lib.ByteCodeLoader;
|
||||||
|
import jdk.test.lib.compiler.InMemoryJavaCompiler;
|
||||||
import jdk.test.lib.process.OutputAnalyzer;
|
import jdk.test.lib.process.OutputAnalyzer;
|
||||||
import jdk.test.lib.process.ProcessTools;
|
import jdk.test.lib.process.ProcessTools;
|
||||||
import jdk.test.whitebox.WhiteBox;
|
import jdk.test.whitebox.WhiteBox;
|
||||||
@ -91,9 +93,6 @@ public class TestMetaSpaceLog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void testMetaSpaceUpdate() throws Exception {
|
private static void testMetaSpaceUpdate() throws Exception {
|
||||||
// Propagate test.src for the jar file.
|
|
||||||
String testSrc= "-Dtest.src=" + System.getProperty("test.src", ".");
|
|
||||||
|
|
||||||
ProcessBuilder pb =
|
ProcessBuilder pb =
|
||||||
ProcessTools.createTestJvm(
|
ProcessTools.createTestJvm(
|
||||||
"-Xlog:gc*",
|
"-Xlog:gc*",
|
||||||
@ -102,7 +101,7 @@ public class TestMetaSpaceLog {
|
|||||||
"-XX:+WhiteBoxAPI",
|
"-XX:+WhiteBoxAPI",
|
||||||
"-Xmx1000M",
|
"-Xmx1000M",
|
||||||
"-Xms1000M",
|
"-Xms1000M",
|
||||||
testSrc, StressMetaSpace.class.getName());
|
StressMetaSpace.class.getName());
|
||||||
|
|
||||||
OutputAnalyzer output = null;
|
OutputAnalyzer output = null;
|
||||||
try {
|
try {
|
||||||
@ -117,29 +116,20 @@ public class TestMetaSpaceLog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static class StressMetaSpace {
|
static class StressMetaSpace {
|
||||||
private static URL[] urls = new URL[1];
|
|
||||||
|
|
||||||
static {
|
|
||||||
try {
|
|
||||||
File jarFile = new File(System.getProperty("test.src") + "/testcases.jar");
|
|
||||||
urls[0] = jarFile.toURI().toURL();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
WhiteBox wb = WhiteBox.getWhiteBox();
|
loadManyClasses();
|
||||||
for(int i = 0; i < 10000; i++) {
|
WhiteBox.getWhiteBox().fullGC();
|
||||||
loadClass(wb);
|
|
||||||
}
|
|
||||||
wb.fullGC();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadClass(WhiteBox wb) {
|
public static void loadManyClasses() {
|
||||||
|
String className = "Tmp";
|
||||||
|
String sourceCode = "public class Tmp {}";
|
||||||
|
byte[] byteCode = InMemoryJavaCompiler.compile(className, sourceCode);
|
||||||
try {
|
try {
|
||||||
URLClassLoader ucl = new URLClassLoader(urls);
|
for (int i = 0; i < 10000; i++) {
|
||||||
Class.forName("case00", false, ucl);
|
ByteCodeLoader.load(className, byteCode);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user