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). This pull request has now been integrated. Changeset: 39190ed7 Author: Alan Bateman <[email protected]> Committer: Chen Liang <[email protected]> URL: https://git.openjdk.org/valhalla/commit/39190ed797ebdfa3bf078943837f697c7501a08c Stats: 392 lines in 4 files changed: 378 ins; 7 del; 7 mod 8387121: [lworld] ISE thrown when attempting to reflectively read strictly-initialized static field before init not specified in API docs Reviewed-by: liach, jpai ------------- PR: https://git.openjdk.org/valhalla/pull/2572
