Skip to content
Permalink
Browse files
8267348: Rewrite gc/epsilon/TestClasses.java to use Metaspace with le…
…ss classes

Reviewed-by: stuefe
  • Loading branch information
shipilev committed May 20, 2021
1 parent ca93399 commit 7b98400c81900a8c779394d549b5fb61f1dd8638
Showing with 16 additions and 5 deletions.
  1. +0 −1 test/hotspot/jtreg/ProblemList.txt
  2. +16 −4 test/hotspot/jtreg/gc/epsilon/TestClasses.java
@@ -83,7 +83,6 @@ gc/stress/gclocker/TestGCLockerWithParallel.java 8180622 generic-all
gc/stress/gclocker/TestGCLockerWithG1.java 8180622 generic-all
gc/stress/TestJNIBlockFullGC/TestJNIBlockFullGC.java 8192647 generic-all
gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java 8241293 macosx-x64
gc/epsilon/TestClasses.java 8267348 linux-x64

#############################################################################

@@ -26,12 +26,12 @@
/**
* @test TestClasses
* @requires vm.gc.Epsilon
* @summary Epsilon is able to allocate a lot of classes
* @summary Epsilon is able to allocate a lot of classes, resizing Metaspace
*
* @modules java.base/jdk.internal.org.objectweb.asm
* java.base/jdk.internal.misc
*
* @run main/othervm -Xmx128m -XX:MetaspaceSize=1m -XX:MaxMetaspaceSize=64m -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -Xlog:gc -Xlog:gc+metaspace gc.epsilon.TestClasses
* @run main/othervm -Xmx1g -XX:MetaspaceSize=1m -XX:MaxMetaspaceSize=64m -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -Xlog:gc -Xlog:gc+metaspace gc.epsilon.TestClasses
*/

import jdk.internal.org.objectweb.asm.ClassWriter;
@@ -44,14 +44,26 @@

public class TestClasses {

static final int COUNT = 32*1024;
static final int CLASSES = 1024;
static final int FIELDS = 1024;

static volatile Object sink;

static class MyClassLoader extends ClassLoader {
static final String[] FIELD_NAMES;
static {
FIELD_NAMES = new String[FIELDS];
for (int c = 0; c < FIELDS; c++) {
FIELD_NAMES[c] = "f" + c;
}
}

public byte[] createClass(String name) {
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
cw.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC | Opcodes.ACC_SUPER, name, null, "java/lang/Object", null);
for (String fName : FIELD_NAMES) {
cw.visitField(Opcodes.ACC_STATIC | Opcodes.ACC_PRIVATE, fName, "J", null, null);
}
return cw.toByteArray();
}

@@ -66,7 +78,7 @@

public static void main(String[] args) throws Exception {
ClassLoader cl = new MyClassLoader();
for (int c = 0; c < COUNT; c++) {
for (int c = 0; c < CLASSES; c++) {
Class<?> clazz = Class.forName("Dummy" + c, true, cl);
if (clazz.getClassLoader() != cl) {
throw new IllegalStateException("Should have loaded by target loader");

1 comment on commit 7b98400

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 7b98400 May 20, 2021

Please sign in to comment.