--- old/test/hotspot/jtreg/runtime/testlibrary/GeneratedClassLoader.java 2018-08-30 16:21:33.679371539 -0400 +++ new/test/hotspot/jtreg/runtime/testlibrary/GeneratedClassLoader.java 2018-08-30 16:21:33.447371548 -0400 @@ -22,6 +22,7 @@ */ import java.io.DataInputStream; +import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileWriter; @@ -145,10 +146,17 @@ pw.append(src); pw.flush(); } - int exitcode = javac.run(null, null, null, file.getCanonicalPath()); + ByteArrayOutputStream err = new ByteArrayOutputStream(); + int exitcode = javac.run(null, null, err, file.getCanonicalPath()); if (exitcode != 0) { - throw new RuntimeException("javac failure when compiling: " + - file.getCanonicalPath()); + // Print Error + System.err.print(err); + if (err.toString().contains("java.lang.OutOfMemoryError: Java heap space")) { + throw new OutOfMemoryError("javac failed with resources exhausted"); + } else { + throw new RuntimeException("javac failure when compiling: " + + file.getCanonicalPath()); + } } else { if (deleteFiles) { file.delete();