Skip to content

Commit 9824212

Browse files
committed
8207793: [TESTBUG] runtime/Metaspace/FragmentMetaspace.java fails: heap needs to be increased
Reduce test time and allow OOM. Reviewed-by: iklam, hseigel
1 parent eb92591 commit 9824212

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

test/hotspot/jtreg/runtime/Metaspace/FragmentMetaspace.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@
2626
* @library /runtime/testlibrary
2727
* @modules java.base/jdk.internal.misc
2828
* @modules java.compiler
29-
* @run main/othervm/timeout=200 -Xmx300m FragmentMetaspace
29+
* @run main/othervm/timeout=200 -Xmx1g FragmentMetaspace
3030
*/
3131

3232
import java.io.IOException;
@@ -42,8 +42,8 @@ public class FragmentMetaspace {
4242
public static Class<?> c;
4343

4444
public static void main(String... args) {
45-
runGrowing(Long.valueOf(System.getProperty("time", "80000")),
46-
Integer.valueOf(System.getProperty("iterations", "200")));
45+
runGrowing(Long.valueOf(System.getProperty("time", "40000")),
46+
Integer.valueOf(System.getProperty("iterations", "100")));
4747
// try to clean up and unload classes to decrease
4848
// class verification time in debug vm
4949
System.gc();
@@ -68,6 +68,9 @@ private static void runGrowing(long time, int iterations) {
6868
gcl = null;
6969
} catch (IOException | InstantiationException | IllegalAccessException ex) {
7070
throw new RuntimeException(ex);
71+
} catch (OutOfMemoryError oome) {
72+
System.out.println("javac failed with OOM; ignored.");
73+
return;
7174
}
7275
}
7376
}

test/hotspot/jtreg/runtime/testlibrary/GeneratedClassLoader.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -22,6 +22,7 @@
2222
*/
2323

2424
import java.io.DataInputStream;
25+
import java.io.ByteArrayOutputStream;
2526
import java.io.File;
2627
import java.io.FileInputStream;
2728
import java.io.FileWriter;
@@ -145,10 +146,17 @@ private GeneratedClass[] getGeneratedClass(int sizeFactor, int numClasses) throw
145146
pw.append(src);
146147
pw.flush();
147148
}
148-
int exitcode = javac.run(null, null, null, file.getCanonicalPath());
149+
ByteArrayOutputStream err = new ByteArrayOutputStream();
150+
int exitcode = javac.run(null, null, err, file.getCanonicalPath());
149151
if (exitcode != 0) {
150-
throw new RuntimeException("javac failure when compiling: " +
151-
file.getCanonicalPath());
152+
// Print Error
153+
System.err.print(err);
154+
if (err.toString().contains("java.lang.OutOfMemoryError: Java heap space")) {
155+
throw new OutOfMemoryError("javac failed with resources exhausted");
156+
} else {
157+
throw new RuntimeException("javac failure when compiling: " +
158+
file.getCanonicalPath());
159+
}
152160
} else {
153161
if (deleteFiles) {
154162
file.delete();

0 commit comments

Comments
 (0)