RFR: 8057113: (fs) Path should have a method to obtain the filename extension [v14]
Brian Burkhalter
bpb at openjdk.org
Wed Jul 27 15:30:57 UTC 2022
On Tue, 26 Jul 2022 20:02:54 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>> src/java.base/share/classes/java/nio/file/Path.java line 305:
>>
>>> 303: } else if (length == 2 &&
>>> 304: !(fileNameString.charAt(0) == '.' ||
>>> 305: fileNameString.charAt(1) != '.')) {
>>
>> I would have coded it as:
>>
>> (length == 2 &&
>> fileNameString.charAt(0) != '.' &&
>> fileNameString.charat(1) == '.')) {
>>
>> As a better match for the comment.
>
> I had it that way originally but changed it thinking that fewer boolean expressions might need to be evaluated.
Changed in 3f510ecc32089589203b1fffb13eedc579aaa8bb.
>> test/jdk/java/nio/file/Path/Extensions.java line 64:
>>
>>> 62: {".profile.sh", "sh"},
>>> 63: {"..foo", "foo"},
>>> 64: {".....foo", "foo"},
>>
>> Duplicates the test of line 53.
>
> Check.
Fixed in 3f510ecc32089589203b1fffb13eedc579aaa8bb.
>> test/jdk/java/nio/file/Path/Extensions.java line 77:
>>
>>> 75: {"x.zip", "zip"},
>>> 76: {"y.gzip", "gzip"},
>>> 77: {"z.jar", "jar"},
>>
>> Fewer test cases of a file with a 3 or 4 character extension would be fine too.
>> Algorithm-wise they are all the same but may give a warm fuzzy that a favorite extension is covered.
>
> Indeed that's all it is. I doubt more than one test of an n-character extension is necessary.
Fixed in 3f510ecc32089589203b1fffb13eedc579aaa8bb.
-------------
PR: https://git.openjdk.org/jdk/pull/8066
More information about the nio-dev
mailing list