Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8314511

WindowsPathParser throws InvalidPathException: Illegal char <:> at index 2

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • None
    • core-libs
    • None

      WindowsPathParser.normalize throws the exception on normalizing path acquired by other java internal methods.

      The following demonstrates the behaviour:
              java.nio.file.Path p;
              p = Paths.get(new URI("file://" + MyTest.class.getResource("").getPath())); // ok
              p = Paths.get(MyTest.class.getResource("").getPath()); // fails

      The stacktrace:
      java.nio.file.InvalidPathException: Illegal char <:> at index 2: /C:/somepath/

      at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:204)
      at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:175)
      at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
      at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
      at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:231)
      at java.base/java.nio.file.Path.of(Path.java:148)
      at java.base/java.nio.file.Paths.get(Paths.java:69)
      at MyTest.testWindowsPath

      At the same time the following works fine:
      FileInputStream fileInputStream = new FileInputStream(MyTest.class.getResource("").getPath() + "/MyTest.class");

            Unassigned Unassigned
            jsupol Jan Supol
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: