RFR: JDK-8319626: Override toString() for ZipFile [v2]
Justin Lu
jlu at openjdk.org
Wed Nov 15 18:33:49 UTC 2023
On Tue, 14 Nov 2023 07:13:41 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> Justin Lu has updated the pull request incrementally with one additional commit since the last revision:
>>
>> reflect review: change string value and drop spec
>
> src/java.base/share/classes/java/util/zip/ZipFile.java line 498:
>
>> 496: */
>> 497: @Override
>> 498: public String toString() {
>
> I don't think the file name on its own is very helpful as it may not be unique or there may be several instances of ZipFile that are backed by the same zip file. Can you try `"" + file + Integer.toHexString(System.identityHashCode(this))` ? Or, if you really want to hide the file path in the String representation, then just use file.getName() + identity string. No need for baseName field. I think we need to be cautious about specifying anything, otherwise code will rely on it.
Hi Alan,
Thanks for taking a look. I updated the toString() value to the one you suggested, and also dropped the specific aspects of the specification.
I am not sure if you have a preference one way or another regarding providing the full path versus just the file name, but I can switch the full path for just the file name if need be.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16643#discussion_r1394622024
More information about the core-libs-dev
mailing list