RFR: JDK-8319626: Override toString() for ZipFile
Alan Bateman
alanb at openjdk.org
Tue Nov 14 07:16:27 UTC 2023
On Mon, 13 Nov 2023 21:59:05 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.
src/java.base/share/classes/java/util/zip/ZipFile.java line 498:
> 496: */
> 497: @Override
> 498: public String toString() {
I don't think this is too helpful as the file name 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(file))` ?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16643#discussion_r1392088054
More information about the core-libs-dev
mailing list