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

Pavel Rappo prappo at openjdk.org
Thu Nov 16 11:22:31 UTC 2023


On Thu, 16 Nov 2023 11:03:30 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 494:
> 
>> 492:     @Override
>> 493:     public String toString() {
>> 494:         return "" + name + Integer.toHexString(System.identityHashCode(this));
> 
> This will give you a String like `foo/bar.zip174d20a`, I think you'll need some separator and "@" is often used with the hex representation of the identity hash. Using `name + "@" + Objects.toIdentityString(this);` is another option to consider.

@justin-curtis-lu, for inspiration and consistency, you might want to have a look at this implementation: https://github.com/openjdk/jdk/blob/1d9688667e667dc710d64e52f1e918e047beaca3/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java#L2605-L2628

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

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


More information about the core-libs-dev mailing list