RFR: 8057113: (fs) Path should have a method to obtain the filename extension [v18]

Stuart Marks smarks at openjdk.org
Wed Aug 3 22:26:24 UTC 2022


On Wed, 3 Aug 2022 15:35:28 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   8057113: Remove API note
>
> src/java.base/share/classes/java/nio/file/Path.java line 272:
> 
>> 270:      * return lastPeriod == fileName.length() - 1 ?
>> 271:      *     "" :
>> 272:      *     fileName.substring(lastPeriod + 1);
> 
> Can L270-272 in the implSpec be cleaned up? It's okay to use the ternary operator but would be easier to read if there is parenthesis around the condition and the ? and : weren't at the end of the lines.

I would suggest that the code in the implSpec be removed. It doesn't add anything and it potentially confuses things. There needs to be an implSpec though since this is a default method. The essential thing to have in implSpec is self-calls on `this`. The only self-call is to `getFileName`, so I'd include in the implSpec some prose to say that `getFileName` is called and (if non-null) is converted to a String, upon which further processing is done.

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

PR: https://git.openjdk.org/jdk/pull/8066


More information about the nio-dev mailing list