RFR: JDK-8319626: Override toString() for ZipFile [v2]
Alan Bateman
alanb at openjdk.org
Thu Nov 16 11:06:32 UTC 2023
On Wed, 15 Nov 2023 18:33:47 GMT, Justin Lu <jlu at openjdk.org> wrote:
>> Please review this PR and [CSR](https://bugs.openjdk.org/browse/JDK-8319982) which overrides and provides an implementation of `toString()` in _java.util.zip.ZipFile_ (and by extension, _java.util.jar.JarFile_).
>>
>> This change is primarily to provide a more informative String representation of the two classes rather than the default hexadecimal representation of the hash code.
>
> 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.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16643#discussion_r1395527831
More information about the core-libs-dev
mailing list