On Fri, 31 Jul 2026 04:05:28 GMT, Chen Liang <[email protected]> wrote:

> The static field VarHandle is missing null checks that blocks incoming nulls.
> 
> The fix is simple; the overwhelming changes come from these areas:
> 1. To introduce a null-restricted set of fields and values, we need to use 
> early initialization and null-restricted array creation for our test 
> templates.
> 2. Added `test(InstanceField|StaticField|Array)NullPointerException` to 
> `VarHandleTest(MethodHandle|)AccessNullRestrictedValue` for the effective 
> unit tests. Without the patch, the `testStaticFieldNullPointerException` 
> fails.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

Looks good.

test/jdk/java/lang/invoke/VarHandles/NullRestrictedValue.java line 28:

> 26:         return new NullRestrictedValue(a, b);
> 27:     }
> 28: }

I'm assuming another type is required since the regular `Value` can not be used 
with null restricted fields?

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

Marked as reviewed by jvernee (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/32115#pullrequestreview-4975236065
PR Review Comment: https://git.openjdk.org/jdk/pull/32115#discussion_r3815489812

Reply via email to