On Fri, 5 Jun 2026 12:45:22 GMT, Casper Norrbin <[email protected]> wrote:

>> Hi everyone,
>> 
>> This change removes the remaining mandatory preloading path for 
>> null-restricted instance fields when loading classes from CDS. 
>> [JDK-8380053](https://bugs.openjdk.org/browse/JDK-8380053) already changed 
>> normal class loading so null-restricted field types are no longer loaded 
>> just because the field is null-restriced. Instead, the preloading is 
>> speculative and driven by the `LoadableDescriptor` attribute. The CDS path 
>> still had the older special case in 
>> `SystemDictionary::preload_from_null_free_field`, which could force loading 
>> of null-restricted field types.
>> 
>> This fix removes that CDS-only preload helper and routes non-static field 
>> signatures through the existing `LoadableDescriptor` path instead. This 
>> makes loading follow the same model as in 
>> `ClassFileParser::fetch_field_classes()` with speculative loading.
>> 
>> Testing:
>> - Tier 1-3
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Casper Norrbin has updated the pull request with a new target base due to a 
> merge or a rebase. The pull request now contains seven commits:
> 
>  - static null-restricted check, new test, other feedback
>  - Merge branch 'lworld' into systemdict-nullrestricted-loading
>  - create symbol only when logging
>  - Merge branch 'lworld' into systemdict-nullrestricted-loading
>  - Validate archived inline field dependencies without LoadableDescriptors
>  - re-add failed marker
>  - removed forced loading for nullrestricted

Following the changes from 
[JDK-8384756](https://bugs.openjdk.org/browse/JDK-8384756), I have updated this 
PR to also validate archived metadata for static null-restricted fields.

The new version:
- Includes classes with `has_null_restricted_static_fields()` in the 
`load_shared_class` field metadata validation loop, and only skips static 
fields that are not null-restricted.
- Updates `get_inline_type_field_klass_or_null()` to allow the static 
null-restricted metadata case.
- Simplifies the flat/null-restricted preload failure logging to use one 
message with a computed failure reason.
- Replaces the old stripped LoadableDescriptors test with 
`ArchivedFieldMetadataMismatchTest`, which now covers both nullable flat 
instance fields and static null-restricted fields. The name did not really 
match what was actually tested, so this new name hopefully matches that better.
- Moves the LoadableDescriptors stripping helper into `TestCommon` and also 
works without the attribute, so that test classes can be copied through the 
same path whether or not they actually have the attribute and can also be 
accessed from other future tests.

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

PR Comment: https://git.openjdk.org/valhalla/pull/2409#issuecomment-4631710709

Reply via email to