RFR: 8335637: Add explicit well-behaved expectations to Object.{toString, hashCode} [v2]
Joe Darcy
darcy at openjdk.org
Mon Jul 8 19:03:32 UTC 2024
On Mon, 8 Jul 2024 17:04:07 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:
> While I understand and agree with the intent, we have several exceptions in the OpenJDK itself.
>
> Circular structures that throw `StackOverflowError` on `hashCode()` and huge numbers that take 20-30 min to compute `toString()` are some examples.
I wouldn't be surprised if there are some cases like that in the JDK. However, if those types are generally usable outside of the JDK, I would advocate for the implementations being updated to behave better.
I added the cyclic/circular guidance in part based on work I did add suppressed exceptions to Throwable in JDK 7. One tricky part of the implementation was making sure the stack trace output did cycle detection since there were various ways exceptions could end up referring to each other.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20063#discussion_r1669136127
More information about the core-libs-dev
mailing list