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).

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

Commit messages:
 - Improve test
 - Expand isStrictInit method description, add test
 - Merge branch 'lworld' into ReflectivelyReadBeforeInit
 - Initial commit

Changes: https://git.openjdk.org/valhalla/pull/2572/files
  Webrev: https://webrevs.openjdk.org/?repo=valhalla&pr=2572&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8387121
  Stats: 392 lines in 4 files changed: 378 ins; 7 del; 7 mod
  Patch: https://git.openjdk.org/valhalla/pull/2572.diff
  Fetch: git fetch https://git.openjdk.org/valhalla.git pull/2572/head:pull/2572

PR: https://git.openjdk.org/valhalla/pull/2572

Reply via email to