< prev index next >

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

Print this page

        

@@ -20,10 +20,11 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
 
 import java.io.DataInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;

@@ -143,14 +144,21 @@
         File file = new File(className + ".java");
         try (PrintWriter pw = new PrintWriter(new FileWriter(file))) {
             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) {
+            // 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();
             }
         }
< prev index next >