[lworld] RFR: 8287241: Add IdentityException to report that a value object is not valid [v2]
Mandy Chung
mchung at openjdk.java.net
Wed Jun 8 21:25:56 UTC 2022
On Wed, 25 May 2022 20:36:52 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.
>
> Roger Riggs has updated the pull request incrementally with one additional commit since the last revision:
>
> Add Objects.requireIdentity(obj, Supplier<String> supplier);
> update copyright
Marked as reviewed by mchung (Committer).
src/java.base/share/classes/java/lang/IdentityException.java line 31:
> 29: * Identity objects are required for synchronization and locking.
> 30: * <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">Value-based</a>
> 31: * objects do not have identity and cannot be used for synchronization or locking.
Need `@since Valhalla`
src/java.base/share/classes/java/lang/IdentityException.java line 35:
> 33: public class IdentityException extends RuntimeException {
> 34: /**
> 35: * Create an IdentityException with no message.
Suggestion:
* Create an {@code IdentityException} with no message.
Same applies to the javadoc of all constructors.
src/java.base/share/classes/java/util/Objects.java line 206:
> 204: Objects.requireNonNull(obj);
> 205: var cl = obj.getClass();
> 206: if (cl.isValue())
Suggestion:
if (obj.getClass().isValue())
Same as the implementation of other variants of the `requireIdentity` method.
-------------
PR: https://git.openjdk.java.net/valhalla/pull/696
More information about the valhalla-dev
mailing list