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). Thanks for working on this. More tests are affected though, for example, `compiler/valhalla/inlinetypes/TestNullableInlineTypes.java`. Could you do a run of all the compiler/valhalla tests with `-XX:-PreloadClasses`? ------------- PR Comment: https://git.openjdk.org/valhalla/pull/2379#issuecomment-4368436080
