On Wed, 13 Dec 2023 19:37:15 GMT, Brian Burkhalter <b...@openjdk.org> wrote:

> Modify the `collapse()` function to remove each instance of ".." when the 
> path is absolute and there is no preceding name.

The change looks okay, the canonical path of a file that does not exist has 
always been hard to reason about.

test/jdk/java/io/File/GetCanonicalPath.java line 98:

> 96:                               "/b/c"));
> 97: 
> 98:         return list.stream();

You could use Stream.of here, e.g.


        return Stream.of(
            Arguments.of("/../../../../../a/b/c", "/a/b/c"),
            Arguments.of("/../../../../../a/../b/c", "/b/c"),
            Arguments.of("/../../../../../a/../../b/c", "/b/c"),
            Arguments.of("/../../../../../a/../../../b/c", "/b/c"),
            Arguments.of("/../../../../../a/../../../../b/c", "/b/c")
        );

-------------

Marked as reviewed by alanb (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/17089#pullrequestreview-1785402494
PR Review Comment: https://git.openjdk.org/jdk/pull/17089#discussion_r1429079490

Reply via email to