On Wed, 16 Apr 2025 17:16:13 GMT, Roger Riggs <[email protected]> wrote:

> The support for CheckedType is replaced by an explicit attribute for 
> NullRestricted. VarHandles for fields and arrays are updated to match.

src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template line 192:

> 190: #if[Reference]
> 191:             if (value == null && handle.nullRestricted)
> 192:                 throw new NullPointerException("Uninitialized 
> null-restricted field");

As I said in <https://github.com/openjdk/jdk/pull/31123#discussion_r3250938433>:
> The message here is wrong, as this method is used for validating the new 
> value to assign to the field:
> ```suggestion
>             if (value == null && handle.nullRestricted) {
>                 throw new NullPointerException("Cannot set null-restricted 
> field to null");
>             }
> ```

-------------

PR Review Comment: 
https://git.openjdk.org/valhalla/pull/1434#discussion_r3335191764

Reply via email to