RFR: JDK-8319626: Override toString() for ZipFile [v4]

Bernd duke at openjdk.org
Wed Nov 29 01:13:06 UTC 2023


On Wed, 15 Nov 2023 18:30:27 GMT, Justin Lu <jlu at openjdk.org> wrote:

>> 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.

I like the new wording (have no oppinion if absolute path is better).

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16643#discussion_r1408597540


More information about the core-libs-dev mailing list