8078861: tools/javac/classfiles/attributes/Synthetic/PackageInfoTest.java fails on Windows
authorjjg
Tue, 28 Apr 2015 18:57:51 -0700
changeset 30067 08fb37c9b670
parent 30066 d74c06a92bd8
child 30068 69f798ac352b
8078861: tools/javac/classfiles/attributes/Synthetic/PackageInfoTest.java fails on Windows Reviewed-by: vromero
langtools/test/tools/javac/classfiles/attributes/Synthetic/SyntheticTestDriver.java
--- a/langtools/test/tools/javac/classfiles/attributes/Synthetic/SyntheticTestDriver.java	Tue Apr 28 22:25:36 2015 +0200
+++ b/langtools/test/tools/javac/classfiles/attributes/Synthetic/SyntheticTestDriver.java	Tue Apr 28 18:57:51 2015 -0700
@@ -21,12 +21,14 @@
  * questions.
  */
 
+import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.*;
 import java.util.function.Function;
 import java.util.function.Supplier;
+import java.util.regex.*;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -69,13 +71,13 @@
                 .collect(Collectors.toMap(ExpectedClass::className, Function.identity()));
         this.classes = new HashMap<>();
         Path classDir = getClassDir().toPath();
-        String sourceFileName = testCaseName.replace('.', '/');
+        Pattern filePattern = Pattern.compile(Pattern.quote(testCaseName.replace('.', File.separatorChar)) + ".*\\.class");
         List<Path> paths = Files.walk(classDir)
                 .map(p -> classDir.relativize(p.toAbsolutePath()))
-                .filter(p -> p.toString().matches(sourceFileName + ".*\\.class"))
+                .filter(p -> filePattern.matcher(p.toString()).matches())
                 .collect(Collectors.toList());
         for (Path path : paths) {
-            String className = path.toString().replace(".class", "").replace('/', '.');
+            String className = path.toString().replace(".class", "").replace(File.separatorChar, '.');
             classes.put(className, readClassFile(classDir.resolve(path).toFile()));
         }
         if (classes.isEmpty()) {