src/windows/classes/sun/nio/fs/WindowsPath.java

Print this page

        

@@ -644,11 +644,13 @@
         return new WindowsPath(getFileSystem(), WindowsPathType.RELATIVE, "", sb.toString());
     }
 
     @Override
     public boolean startsWith(Path obj) {
-        WindowsPath other = toWindowsPath(obj);
+        if (!(Objects.requireNonNull(obj) instanceof WindowsPath))
+            return false;
+        WindowsPath other = (WindowsPath)obj;
 
         // if this path has a root component the given path's root must match
         if (!this.root.equalsIgnoreCase(other.root)) {
             return false;
         }

@@ -673,11 +675,13 @@
         return false;
     }
 
     @Override
     public boolean endsWith(Path obj) {
-        WindowsPath other = toWindowsPath(obj);
+        if (!(Objects.requireNonNull(obj) instanceof WindowsPath))
+            return false;
+        WindowsPath other = (WindowsPath)obj;
 
         // other path is longer
         if (other.path.length() > this.path.length()) {
             return false;
         }