On Thu, 30 Apr 2026 09:59:05 GMT, Paul Hübner <[email protected]> wrote:
> 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). This pull request has now been integrated. Changeset: 2bc2fe39 Author: Paul Hübner <[email protected]> URL: https://git.openjdk.org/valhalla/commit/2bc2fe398e7b48f72729641bcd5f574aebbcfa2b Stats: 25 lines in 4 files changed: 25 ins; 0 del; 0 mod 8383627: [lworld] Failures with -XX:-PreloadClasses after JDK-8383242 Reviewed-by: thartmann, jsikstro ------------- PR: https://git.openjdk.org/valhalla/pull/2379
