8178727: CTW should provide class names in error messages
authoriignatyev
Fri, 14 Apr 2017 15:47:33 -0700
changeset 46385 6b890c9a717f
parent 46384 dacebddcdea0
child 46386 742f8b16d00c
8178727: CTW should provide class names in error messages Reviewed-by: kvn
hotspot/test/testlibrary/ctw/src/sun/hotspot/tools/ctw/CtwRunner.java
--- a/hotspot/test/testlibrary/ctw/src/sun/hotspot/tools/ctw/CtwRunner.java	Thu Apr 13 16:38:39 2017 -0400
+++ b/hotspot/test/testlibrary/ctw/src/sun/hotspot/tools/ctw/CtwRunner.java	Fri Apr 14 15:47:33 2017 -0700
@@ -25,6 +25,7 @@
 
 import jdk.test.lib.Utils;
 import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.util.Pair;
 
 import java.io.IOException;
 import java.nio.file.Files;
@@ -120,20 +121,21 @@
                 System.out.printf("%s %dms END : exit code = %d%n",
                         phase, TimeUnit.NANOSECONDS.toMillis(System.nanoTime()),
                         exitCode);
-                long lastClassIndex = getLastClassIndex(out);
+                Pair<String, Long> lastClass = getLastClass(out);
                 if (exitCode == 0) {
                     done = true;
                 } else {
-                    if (lastClassIndex == 0) {
+                    if (lastClass == null) {
                         errors.add(new Error(phase + ": failed during preload"
                                 + " with classStart = " + classStart));
                         // skip one class
                         ++classStart;
                     } else {
                         errors.add(new Error(phase + ": failed during"
-                                + " compilation of class #" + lastClassIndex));
+                                + " compilation of class #" + lastClass.second
+                                + " : " + lastClass.first));
                         // continue with the next class
-                        classStart = lastClassIndex + 1;
+                        classStart = lastClass.second + 1;
                     }
                 }
             } catch (Exception e) {
@@ -142,8 +144,7 @@
         }
     }
 
-    private long getLastClassIndex(Path errFile) {
-        long result = 0;
+    private Pair<String, Long> getLastClass(Path errFile) {
         try {
             String line = Files.newBufferedReader(errFile)
                     .lines()
@@ -152,13 +153,15 @@
             if (line != null) {
                 int open = line.indexOf('[') + 1;
                 int close = line.indexOf(']');
-                result = Long.parseLong(line.substring(open, close));
+                long index = Long.parseLong(line.substring(open, close));
+                String name = line.substring(close + 1).trim().replace('.', '/');
+                return new Pair<>(name, index);
             }
         } catch (IOException ioe) {
             throw new Error("can not read " + errFile + " : "
                     + ioe.getMessage(), ioe);
         }
-        return result;
+        return null;
     }
 
     private String[] cmd(long classStart) {
@@ -178,9 +181,10 @@
                 "--add-exports", "java.base/jdk.internal.reflect=ALL-UNNAMED",
                 // enable diagnostic logging
                 "-XX:+LogCompilation",
-                // use phase specific log and hs_err file
+                // use phase specific log, hs_err and ciReplay files
                 String.format("-XX:LogFile=hotspot_%s_%%p.log", phase),
                 String.format("-XX:ErrorFile=hs_err_%s_%%p.log", phase),
+                String.format("-XX:ReplayDataFile=replay_%s_%%p.log", phase),
                 // MethodHandle MUST NOT be compiled
                 "-XX:CompileCommand=exclude,java/lang/invoke/MethodHandle.*",
                 // CTW entry point