From 77fa3101ec325a151a661ddb042fecd2ccb9f6a6 Mon Sep 17 00:00:00 2001 From: Andreas Lundblad Date: Thu, 12 Jun 2014 14:29:09 +0200 Subject: [PATCH] 8042830: A recently added Xprefer test fails on Windows Test now accepts both / and \ as file separator. Reviewed-by: mcimadamore --- .../tools/javac/options/xprefer/XPreferTest.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/langtools/test/tools/javac/options/xprefer/XPreferTest.java b/langtools/test/tools/javac/options/xprefer/XPreferTest.java index 7d9c6da190e..3a95718fe36 100644 --- a/langtools/test/tools/javac/options/xprefer/XPreferTest.java +++ b/langtools/test/tools/javac/options/xprefer/XPreferTest.java @@ -26,7 +26,6 @@ * @summary Tests which path is used to represent an implicit type given * various xprefer arguments and multiple .class / .java files involved. * @bug 8028196 - * @ignore 8042839 XPreferTest fails on Windows */ import java.io.File; @@ -42,6 +41,7 @@ import java.util.List; import java.util.ListIterator; import java.util.NoSuchElementException; import java.util.Scanner; +import java.util.regex.Pattern; import javax.tools.JavaCompiler; import javax.tools.JavaCompiler.CompilationTask; @@ -180,10 +180,16 @@ public class XPreferTest { Scanner s = new Scanner(compilerOutput); while (s.hasNextLine()) { String line = s.nextLine(); - if (line.matches("\\[loading .*\\]")) - for (Dir dir : Dir.values()) - if (line.contains(dir.file.getName() + "/" + classId)) + if (line.matches("\\[loading .*\\]")) { + for (Dir dir : Dir.values()) { + // On Windows all paths are printed with '/' except + // paths inside zip-files, which are printed with '\'. + // For this reason we accept both '/' and '\' below. + String regex = dir.file.getName() + "[\\\\/]" + classId; + if (Pattern.compile(regex).matcher(line).find()) return dir; + } + } } return null; }