[lworld] RFR: 8287241: Add IdentityException to report that a value object is not valid
ExE Boss
duke at openjdk.java.net
Wed May 25 19:21:01 UTC 2022
On Tue, 24 May 2022 18:25:18 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
> Add class java.lang.IdentityException, when thrown indicates that an identity object was required but a value object was supplied.
>
> Also add methods `java.util.Objects.requireIdentity(obj)` and `Objects.requireIdentity(obj, message)` to check and throw.
>
> Updated java.lang.ref.Reference and related tests to use new exception and method.
There should probably also be a `requireIdentity(T obj, Supplier<String> messageSupplier)` overload, like there is for `requireNonNull`:
https://github.com/openjdk/valhalla/blob/eb1682287408033bf1c7738a95cc11a5d73ff7aa/src/java.base/share/classes/java/util/Objects.java#L397-L402
-------------
PR: https://git.openjdk.java.net/valhalla/pull/696
More information about the valhalla-dev
mailing list