Skip to content
Permalink
Browse files
8267404: vmTestbase/vm/mlvm/anonloader/stress/oome/metaspace/Test.jav…
…a failed with OutOfMemoryError

Co-authored-by: xiangyuan <xiangyuan@tencent.com>
Reviewed-by: stuefe
  • Loading branch information
DamonFool and ldaxr committed May 22, 2021
1 parent 71e2fa2 commit 6288a9936cc7e69cab0cc5f3e49c803f184bf2ca
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 50 deletions.
@@ -154,7 +154,6 @@ vmTestbase/vm/mlvm/meth/stress/jdi/breakpointInCompiledCode/Test.java 8257761 ge
vmTestbase/vm/mlvm/indy/func/jvmti/mergeCP_indy2none_a/TestDescription.java 8013267 generic-all
vmTestbase/vm/mlvm/indy/func/jvmti/mergeCP_indy2manyDiff_b/TestDescription.java 8013267 generic-all
vmTestbase/vm/mlvm/indy/func/jvmti/mergeCP_indy2manySame_b/TestDescription.java 8013267 generic-all
vmTestbase/vm/mlvm/anonloader/stress/oome/metaspace/Test.java 8267404 linux-aarch64

vmTestbase/nsk/jdwp/ThreadReference/ForceEarlyReturn/forceEarlyReturn001/forceEarlyReturn001.java 7199837 generic-all

@@ -24,69 +24,38 @@

/*
* @test
* @modules java.base/jdk.internal.misc
*
* @summary converted from VM Testbase vm/mlvm/anonloader/stress/oome/metaspace.
* VM Testbase keywords: [feature_mlvm, nonconcurrent]
*
* @library /vmTestbase
* /test/lib
* @library /test/lib
*
* @comment build test class and indify classes
* @build vm.mlvm.anonloader.stress.oome.metaspace.Test
* @run driver vm.mlvm.share.IndifiedClassesBuilder
*
* @run main/othervm -Xmx256m -XX:-UseGCOverheadLimit -XX:MaxMetaspaceSize=8m vm.mlvm.anonloader.stress.oome.metaspace.Test
* @run driver vm.mlvm.anonloader.stress.oome.metaspace.Test
*/

package vm.mlvm.anonloader.stress.oome.metaspace;

import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodHandles.Lookup;
import java.util.List;
import java.io.IOException;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;

import vm.mlvm.anonloader.share.AnonkTestee01;
import vm.mlvm.share.MlvmOOMTest;
import vm.mlvm.share.MlvmTestExecutor;
import vm.mlvm.share.Env;
import vm.share.FileUtils;
public class Test {

/**
* This test loads classes using defineHiddenClass and stores them,
* expecting Metaspace OOME.
*
*/
public class Test extends MlvmOOMTest {
@Override
protected void checkOOME(OutOfMemoryError oome) {
String message = oome.getMessage();
if (!"Metaspace".equals(message) && !"Compressed class space".equals(message)) {
throw new RuntimeException("TEST FAIL : wrong OOME", oome);
public static void main(String[] args) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-Xshare:off", "-XX:MaxMetaspaceSize=512k", "-version");

OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());

analyzer.shouldNotHaveExitValue(0);

if (!analyzer.getStdout().contains("OutOfMemoryError")) {
throw new RuntimeException("TEST FAIL : no OOME");
}
}

@Override
protected void eatMemory(List<Object> list) {
byte[] classBytes = null;
try {
classBytes = FileUtils.readClass(AnonkTestee01.class.getName());
} catch (IOException e) {
Env.throwAsUncheckedException(e);
if (!analyzer.getStdout().contains("Metaspace") &&
!analyzer.getStdout().contains("Compressed class space")) {
throw new RuntimeException("TEST FAIL : wrong OOME");
}
try {
while (true) {
Lookup lookup = MethodHandles.lookup();
Lookup ank_lookup = MethodHandles.privateLookupIn(AnonkTestee01.class, lookup);
Class<?> c = ank_lookup.defineHiddenClass(classBytes, true).lookupClass();
list.add(c.newInstance());
}
} catch (InstantiationException | IllegalAccessException e) {
Env.throwAsUncheckedException(e);
}
}

public static void main(String[] args) {
MlvmTestExecutor.launch(args);
}
}

1 comment on commit 6288a99

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 6288a99 May 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.