Hello.
I found suspicious condition in implementation of method
JrtFileSystem.getPathMatcher(String)
https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java#L178

    public PathMatcher getPathMatcher(String syntaxAndInput) {
        int pos = syntaxAndInput.indexOf(':');
        if (pos <= 0 || pos == syntaxAndInput.length()) {
            throw new IllegalArgumentException("pos is " + pos);
        }

Variable pos is a result of String.indexOf(char) call. It is compared
with the length() of the same String.
This condition 'pos == syntaxAndInput.length()' will always be false:
String.indexOf() can't return any value greater than length()-1.
Perhaps it was intended to be 'pos == syntaxAndInput.length() - 1'?


BTW, I think exception message could be improved. Current message 'pos
is -1' is not user friendly.

Andrey Turbanov

Reply via email to