changeset 46385:6b890c9a717f

8178727: CTW should provide class names in error messages Reviewed-by: kvn
author iignatyev
date Fri, 14 Apr 2017 15:47:33 -0700
parents dacebddcdea0
children 742f8b16d00c
files hotspot/test/testlibrary/ctw/src/sun/hotspot/tools/ctw/CtwRunner.java
diffstat 1 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- 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