changeset 46357:5873f29039bb

Merge
author rbackman
date Tue, 28 Mar 2017 13:33:50 +0200
parents dedf3d5f3332 46e3aa269de0
children 10e532e20c7d
files
diffstat 7 files changed, 69 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/hotspot/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/collect/ClassSource.java	Mon Mar 20 16:01:33 2017 +0300
+++ b/hotspot/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/collect/ClassSource.java	Tue Mar 28 13:33:50 2017 +0200
@@ -31,6 +31,20 @@
         return fileName.endsWith(".class") && !fileName.endsWith("module-info.class");
     }
 
+    static String stripRoot(Path path) {
+      if (path.getRoot() != null) {
+        String root = path.getRoot().toString();
+        String filename = path.toString().substring(root.length());
+        String separator = path.getFileSystem().getSeparator();
+        while (filename.startsWith(separator)) {
+          filename = filename.substring(separator.length());
+        }
+        return filename;
+      }
+
+      return path.toString();
+    }
+
     static String makeClassName(Path path) {
         String fileName = path.toString();
 
@@ -38,13 +52,10 @@
             throw new IllegalArgumentException("File doesn't end with .class: '" + fileName + "'");
         }
 
-        int start = 0;
-        if (fileName.startsWith("/")) {
-            start = 1;
-        }
+        fileName = stripRoot(path);
 
-        String className = fileName.substring(start, fileName.length() - ".class".length());
-        className = className.replace('/', '.');
+        String className = fileName.substring(0, fileName.length() - ".class".length());
+        className = className.replace(path.getFileSystem().getSeparator(), ".");
         return className;
     }
 
--- a/hotspot/test/ProblemList.txt	Mon Mar 20 16:01:33 2017 +0300
+++ b/hotspot/test/ProblemList.txt	Tue Mar 28 13:33:50 2017 +0200
@@ -106,12 +106,6 @@
 compiler/aot/calls/fromCompiled/CompiledInvokeDynamic2AotTest.java 8175791 windows-all
 compiler/aot/DeoptimizationTest.java 8175791 windows-all
 
-# aot tests failing due to JDK-8177069
-compiler/aot/jdk.tools.jaotc.test/src/jdk/tools/jaotc/test/collect/ClassSourceTest.java 8177069 windows-all
-compiler/aot/jdk.tools.jaotc.test/src/jdk/tools/jaotc/test/collect/SearchPathTest.java 8177069 windows-all
-compiler/aot/jdk.tools.jaotc.test/src/jdk/tools/jaotc/test/collect/jar/JarSourceProviderTest.java 8177069 windows-all
-compiler/aot/jdk.tools.jaotc.test/src/jdk/tools/jaotc/test/collect/module/ModuleSourceProviderTest.java 8177069 windows-all
-
 #############################################################################
 
 # :hotspot_gc
--- a/hotspot/test/compiler/aot/jdk.tools.jaotc.test/src/jdk/tools/jaotc/test/collect/ClassSourceTest.java	Mon Mar 20 16:01:33 2017 +0300
+++ b/hotspot/test/compiler/aot/jdk.tools.jaotc.test/src/jdk/tools/jaotc/test/collect/ClassSourceTest.java	Tue Mar 28 13:33:50 2017 +0200
@@ -25,6 +25,7 @@
  * @test
  * @modules jdk.aot/jdk.tools.jaotc
  *          jdk.aot/jdk.tools.jaotc.collect
+ * @build jdk.tools.jaotc.test.collect.Utils
  * @run junit/othervm jdk.tools.jaotc.test.collect.ClassSourceTest
  */
 
@@ -37,6 +38,8 @@
 
 import static jdk.tools.jaotc.collect.ClassSource.makeClassName;
 
+import static jdk.tools.jaotc.test.collect.Utils.getpath;
+
 public class ClassSourceTest {
     @Test(expected=IllegalArgumentException.class)
     public void itShouldThrowExceptionIfPathDoesntEndWithClass() {
@@ -45,16 +48,16 @@
 
     @Test
     public void itShouldReplaceSlashesWithDots() {
-        Assert.assertEquals("foo.Bar", makeClassName(Paths.get("foo/Bar.class")));
+        Assert.assertEquals("foo.Bar", makeClassName(getpath("foo/Bar.class")));
     }
 
     @Test
     public void itShouldStripLeadingSlash() {
-        Assert.assertEquals("Hello", makeClassName(Paths.get("/Hello.class")));
+        Assert.assertEquals("Hello", makeClassName(getpath("/Hello.class")));
     }
 
     @Test
     public void itShouldReplaceMultipleDots() {
-        Assert.assertEquals("some.foo.bar.FooBar", makeClassName(Paths.get("/some/foo/bar/FooBar.class")));
+        Assert.assertEquals("some.foo.bar.FooBar", makeClassName(getpath("/some/foo/bar/FooBar.class")));
     }
 }
--- a/hotspot/test/compiler/aot/jdk.tools.jaotc.test/src/jdk/tools/jaotc/test/collect/SearchPathTest.java	Mon Mar 20 16:01:33 2017 +0300
+++ b/hotspot/test/compiler/aot/jdk.tools.jaotc.test/src/jdk/tools/jaotc/test/collect/SearchPathTest.java	Tue Mar 28 13:33:50 2017 +0200
@@ -44,6 +44,8 @@
 import jdk.tools.jaotc.collect.*;
 
 import static jdk.tools.jaotc.test.collect.Utils.set;
+import static jdk.tools.jaotc.test.collect.Utils.mkpath;
+import static jdk.tools.jaotc.test.collect.Utils.mkpaths;
 import static org.junit.Assert.*;
 
 public class SearchPathTest {
@@ -57,9 +59,9 @@
 
     @Test
     public void itShouldUsePathIfPathIsAbsoluteAndExisting() {
-        fileSupport = new FakeFileSupport(set("/foo"), set());
+        fileSupport = new FakeFileSupport(mkpaths("/foo"), set());
         SearchPath target = new SearchPath(fileSupport);
-        Path foo = Paths.get("/foo");
+        Path foo = Paths.get(mkpath("/foo"));
         Path result = target.find(fs, foo);
         assertSame(result, foo);
     }
@@ -68,13 +70,13 @@
     public void itShouldReturnNullIfPathIsAbsoluteAndNonExisting() {
         fileSupport = new FakeFileSupport(set(), set());
         SearchPath target = new SearchPath(fileSupport);
-        Path result = target.find(fs, Paths.get("/bar"));
+        Path result = target.find(fs, Paths.get(mkpath("/bar")));
         assertNull(result);
     }
 
     @Test
     public void itShouldUseRelativeExisting() {
-        fileSupport = new FakeFileSupport(set("hello", "tmp/hello", "search/hello"), set());
+        fileSupport = new FakeFileSupport(mkpaths("hello", "tmp/hello", "search/hello"), set());
         SearchPath target = new SearchPath(fileSupport);
         target.add("search");
         Path hello = Paths.get("hello");
@@ -84,22 +86,22 @@
 
     @Test
     public void itShouldSearchDefaultsBeforeSearchPaths() {
-        fileSupport = new FakeFileSupport(set("bar/foobar"), set());
+        fileSupport = new FakeFileSupport(mkpaths("bar/foobar"), set());
         SearchPath target = new SearchPath(fileSupport);
         Path result = target.find(fs, Paths.get("foobar"), "default1", "bar");
-        assertEquals("bar/foobar", result.toString());
-        assertEquals(set("foobar", "default1/foobar", "bar/foobar"), fileSupport.getCheckedExists());
+        assertEquals(mkpath("bar/foobar"), result.toString());
+        assertEquals(mkpaths("foobar", "default1/foobar", "bar/foobar"), fileSupport.getCheckedExists());
     }
 
     @Test
     public void itShouldUseSearchPathsIfNotInDefaults() {
-        fileSupport = new FakeFileSupport(set("bar/tmp/foobar"), set());
+        fileSupport = new FakeFileSupport(mkpaths("bar/tmp/foobar"), set());
         SearchPath target = new SearchPath(fileSupport);
         target.add("foo/tmp", "bar/tmp");
 
         Path result = target.find(fs, Paths.get("foobar"), "foo", "bar");
-        assertEquals("bar/tmp/foobar", result.toString());
-        assertEquals(set("foobar", "foo/foobar", "bar/foobar", "bar/tmp/foobar", "foo/tmp/foobar"), fileSupport.getCheckedExists());
+        assertEquals(mkpath("bar/tmp/foobar"), result.toString());
+        assertEquals(mkpaths("foobar", "foo/foobar", "bar/foobar", "bar/tmp/foobar", "foo/tmp/foobar"), fileSupport.getCheckedExists());
     }
 
     @Test
@@ -110,6 +112,6 @@
 
         Path result = target.find(fs, Paths.get("entry"), "dir3", "dir4");
         assertNull(result);
-        assertEquals(set("entry", "dir1/entry", "dir2/entry", "dir3/entry", "dir4/entry"), fileSupport.getCheckedExists());
+        assertEquals(mkpaths("entry", "dir1/entry", "dir2/entry", "dir3/entry", "dir4/entry"), fileSupport.getCheckedExists());
     }
 }
--- a/hotspot/test/compiler/aot/jdk.tools.jaotc.test/src/jdk/tools/jaotc/test/collect/Utils.java	Mon Mar 20 16:01:33 2017 +0300
+++ b/hotspot/test/compiler/aot/jdk.tools.jaotc.test/src/jdk/tools/jaotc/test/collect/Utils.java	Tue Mar 28 13:33:50 2017 +0200
@@ -22,6 +22,9 @@
  */
 package jdk.tools.jaotc.test.collect;
 
+import java.io.File;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -33,4 +36,23 @@
         }
         return set;
     }
+
+    public static String mkpath(String path) {
+        return getpath(path).toString();
+    }
+
+    public static Set<String> mkpaths(String... paths) {
+        Set<String> set = new HashSet<String>();
+        for (String entry : paths) {
+            set.add(mkpath(entry));
+        }
+        return set;
+    }
+
+    public static Path getpath(String path) {
+        if (path.startsWith("/") && System.getProperty("os.name").startsWith("Windows")) {
+            path = new File(path).getAbsolutePath();
+        }
+        return Paths.get(path);
+    }
 }
--- a/hotspot/test/compiler/aot/jdk.tools.jaotc.test/src/jdk/tools/jaotc/test/collect/jar/JarSourceProviderTest.java	Mon Mar 20 16:01:33 2017 +0300
+++ b/hotspot/test/compiler/aot/jdk.tools.jaotc.test/src/jdk/tools/jaotc/test/collect/jar/JarSourceProviderTest.java	Tue Mar 28 13:33:50 2017 +0200
@@ -48,6 +48,7 @@
 import java.nio.file.ProviderNotFoundException;
 import java.util.Set;
 
+import static jdk.tools.jaotc.test.collect.Utils.mkpath;
 import static jdk.tools.jaotc.test.collect.Utils.set;
 
 public class JarSourceProviderTest {
@@ -84,7 +85,7 @@
         ClassSource source = target.findSource("foobar", new FakeSearchPath("hello/foobar"));
 
         Assert.assertNull(source);
-        Assert.assertEquals(set("hello/foobar"), fileSupport.getCheckedDirectory());
+        Assert.assertEquals(set(mkpath("hello/foobar")), fileSupport.getCheckedDirectory());
     }
 
     @Test
@@ -92,7 +93,7 @@
         fileSupport.setJarFileSystemRoot(null);
         ClassSource result = target.findSource("foobar", new FakeSearchPath("foo/bar"));
 
-        Assert.assertEquals(set("foo/bar"), fileSupport.getCheckedJarFileSystemRoots());
+        Assert.assertEquals(set(mkpath("foo/bar")), fileSupport.getCheckedJarFileSystemRoots());
         Assert.assertNull(result);
     }
 
@@ -111,7 +112,7 @@
 
         ClassSource result = target.findSource("foobar", new FakeSearchPath("foo/bar"));
 
-        Assert.assertEquals(set("foo/bar"), fileSupport.getCheckedJarFileSystemRoots());
+        Assert.assertEquals(set(mkpath("foo/bar")), fileSupport.getCheckedJarFileSystemRoots());
         Assert.assertNull(result);
     }
 
@@ -120,7 +121,7 @@
         fileSupport.setJarFileSystemRoot(Paths.get("some/bar"));
         ClassSource result = target.findSource("foobar", new FakeSearchPath("this/bar"));
 
-        Assert.assertEquals(set("this/bar"), fileSupport.getClassloaderPaths());
-        Assert.assertEquals("jar:this/bar", result.toString());
+        Assert.assertEquals(set(mkpath("this/bar")), fileSupport.getClassloaderPaths());
+        Assert.assertEquals("jar:" + mkpath("this/bar"), result.toString());
     }
 }
--- a/hotspot/test/compiler/aot/jdk.tools.jaotc.test/src/jdk/tools/jaotc/test/collect/module/ModuleSourceProviderTest.java	Mon Mar 20 16:01:33 2017 +0300
+++ b/hotspot/test/compiler/aot/jdk.tools.jaotc.test/src/jdk/tools/jaotc/test/collect/module/ModuleSourceProviderTest.java	Tue Mar 28 13:33:50 2017 +0200
@@ -46,9 +46,12 @@
 import java.nio.file.Paths;
 import java.util.function.BiFunction;
 
+import static jdk.tools.jaotc.test.collect.Utils.mkpath;
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 
+
 public class ModuleSourceProviderTest {
     private ClassLoader classLoader;
     private ModuleSourceProvider target;
@@ -86,8 +89,8 @@
         };
 
         ModuleSource source = (ModuleSource) target.findSource("test.module", null);
-        assertEquals("modules/test.module", source.getModulePath().toString());
-        assertEquals("module:modules/test.module", source.toString());
+        assertEquals(mkpath("modules/test.module"), source.getModulePath().toString());
+        assertEquals("module:" + mkpath("modules/test.module"), source.toString());
     }
 
     private static class FakeClassLoader extends ClassLoader {