On Mon, 22 Jun 2026 13:24:22 GMT, Alan Bateman <[email protected]> wrote:

> getstatic is specified/implement to throw ISE if a strictly-initialized 
> static field is unset.  The reflection APIs are implemented to do the same 
> but it doesn't surface in the API docs.
> 
> Field.getXXX is updated to specify the exception. Each getXXX method already 
> specifies EIIE so it doesn't look out of place, and seems preferable to 
> putting in the class description of isStrictInit. Doing the equivalent in 
> MH/VH would add a lot of clutter so instead factory methods that produce a 
> MH/VH to read a static field are updated. These methods already specify that 
> they may provoke the field's class to be initialized so an additional 
> sentence on invoking/operating-on while initializing the class doesn't look 
> out of place.
> 
> StrictInitializingTest tests MH/VH access to a field that is unset but we 
> don't seem to have tests for Field. Adding a simple test for Field.get and 
> the MH/VH produced from a Field, and another test for FIeld.isStrictInit so 
> its behavior when preview features are disabled and enabled is tested.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

Thanks, my rationale for the classfile version request is that when Strict 
Field Initialization graduates from preview, maintainers may know how to update 
`IsStrictInitTest` instead of accidentally deleting it, thinking it tests 
something only applicable to preview.

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

Marked as reviewed by liach (Committer).

PR Review: 
https://git.openjdk.org/valhalla/pull/2572#pullrequestreview-4557919971

Reply via email to