Hi all,

This skips the test `TestFieldNullMarkers.java` when `-XX:-PreloadClasses` is 
specified.

According to [JDK-8380053](https://bugs.openjdk.org/browse/JDK-8380053), the 
semantics of `@NullRestricted` are as follows:
> The proposed new interpretation of the @NullRestricted annotation is as 
> follows:
>  - if the type of the field has been loaded during the preloading process and 
> is a concrete value class, then the  @NullRestricted semantic is applied to 
> the field
>  - if the type of the field cannot / has not been loaded during the 
> preloading process, or the loaded type is not a concrete value class, then 
> the annotation is ignored

Since `-PreloadClasses` is specified, when the test is loaded, the classes of 
its `@NullRestricted` fields are not loaded. Therefore, these fields cannot be 
treated as null-restricted in accordance to the above semantics. 
Consequently, the test is throwing `java.lang.RuntimeException: No NPE thrown` 
because the VM permits a null-write to what it considers a regular field.

This was not noticed until 
[JDK-8383242](https://bugs.openjdk.org/browse/JDK-8383242) was integrated, as 
the semantics were not applied in the VM due to a bug this CR fixed. 

Testing: tier 1, running this test locally with all constellations of the flag, 
and Oracle-internal tests. 

---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK 
Interim AI Policy](https://openjdk.org/legal/ai).

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

Commit messages:
 - Skip test when not preloading classes.

Changes: https://git.openjdk.org/valhalla/pull/2379/files
  Webrev: https://webrevs.openjdk.org/?repo=valhalla&pr=2379&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8383627
  Stats: 14 lines in 1 file changed: 14 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/valhalla/pull/2379.diff
  Fetch: git fetch https://git.openjdk.org/valhalla.git pull/2379/head:pull/2379

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

Reply via email to