On Wed, 8 Oct 2025 15:29:37 GMT, Roger Riggs <[email protected]> wrote:
>> Ah, but HAS_PREVIEW_VERSION is never set on a preview location. It's only
>> for non-preview locations to indicate that a (different) preview version
>> exists.
>>
>> HAS_PREVIEW_VERSION can also be set for /packages/xxx directory entries
>> (where it means "some of the entries are modules in which preview versions
>> of resources exist" rather than "there's a META-INF/preview version of this
>> entry"). IS_PREVIEW_VERSION is kind of meaningless for the /packages/xxx
>> directories though, and is never set on them.
>>
>> I'm not sure I'm a fan of trying to merge the semantics of these into some
>> sort of "HAS_OR_IS_PREVIEW_VERSION" flag though. We're not short on flag
>> space (and are extremely unlikely to ever be).
>
> I see the semantics of the flag as `there-is-a-preview-version` of the
> resource.
> Where-ever it appears, it means that the resource/class is in the preview
> branch of the hierarchy.
> If the flag appears in the normal hierarchy index, it still means the same,
> look in the preview hierarchy.
> If it appears on a directory, it means there preview resources in/below.
There is no "*the* resource/class" in the jimage file, because both can be
present. It depends on whether the path to the entry contains META-INF/preview
or not. So where a normal resource has a preview version, the same flag would
be set on both.
For example, I don't see how this works if the flags have the same value.
// Regardless of preview mode, don't return resources requested directly
// via their preview path.
if ((flags & ImageLocation::FLAGS_IS_PREVIEW_VERSION) != 0) {
return 0L;
}
// Even if there is a preview version, we might not want to return it.
if (!is_preview_mode || (flags & ImageLocation::FLAGS_HAS_PREVIEW_VERSION)
== 0) {
return locOffset;
}
-------------
PR Review Comment:
https://git.openjdk.org/valhalla/pull/1619#discussion_r2414524082