RFR: JDK-8319626: Override toString() for ZipFile [v2]
Pavel Rappo
prappo at openjdk.org
Thu Nov 16 11:25:32 UTC 2023
On Thu, 16 Nov 2023 11:19:39 GMT, Pavel Rappo <prappo at openjdk.org> wrote:
>> 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
Generally, search codebase for `super.toString()` to get some idea as to how people incorporate superclass `toString()` into subclass one.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16643#discussion_r1395549078
More information about the core-libs-dev
mailing list