test/hotspot/jtreg/runtime/cds/appcds/TestCommon.java
changeset 59236 e2ee246e44e3
parent 58990 7f1d2c3a99da
equal deleted inserted replaced
59235:0f41ac6bb9dd 59236:e2ee246e44e3
   660              }
   660              }
   661              Files.createSymbolicLink(linkedJar.toPath(), origJar.toPath());
   661              Files.createSymbolicLink(linkedJar.toPath(), origJar.toPath());
   662          }
   662          }
   663          return linkedJar;
   663          return linkedJar;
   664     }
   664     }
       
   665 
       
   666     // Remove all UL log messages from a JVM's STDOUT (such as those printed by -Xlog:cds)
       
   667     static Pattern logPattern = Pattern.compile("^\\[[0-9. ]*s\\].*");
       
   668     public static String filterOutLogs(String stdout) {
       
   669         StringBuilder sb = new StringBuilder();
       
   670         String prefix = "";
       
   671         for (String line : stdout.split("\n")) {
       
   672             if (logPattern.matcher(line).matches()) {
       
   673                 continue;
       
   674             }
       
   675             sb.append(prefix);
       
   676             sb.append(line);
       
   677             prefix = "\n";
       
   678         }
       
   679         if (stdout.endsWith("\n")) {
       
   680             // String.split("A\n") returns {"A"}, not {"A", ""}.
       
   681             sb.append("\n");
       
   682         }
       
   683         return sb.toString();
       
   684     }
   665 }
   685 }