On Mon, 9 Mar 2026 18:11:07 GMT, Chen Liang <[email protected]> wrote:

> Currently, the preview access flag enum constants are made available with a 
> ClassFileFormatVersion.CURRENT_PREVIEW_FEATURES constant. Such a constant is 
> questionable design.
> 
> We can have an approach to model preview access flags without such a 
> constant, losing the ability for users to inspect through 
> `ClassFileFormatVersion`, but otherwise keeping these interfaces intact:
> 
> 1. `accessFlags()` factory methods in core reflection
> 2. Inspection of AccessFlag through ClassFile API
> 3. The outputs of javap
> 
> The new design makes use of a new internal API, 
> `jdk.internal.reflect.PreviewAccessFlags`. It replaces the AccessFlag APIs 
> that previously took `ClassFileFormatVersion.CURRENT_PREVIEW_FEATURES`. This 
> introduces a new qualified export from `java.base/jdk.internal.reflect` to 
> `jdk.jdeps` for Javap usage.
> 
> In addition, with the recent awareness that core reflection/HotSpot only has 
> one unique representation of modifiers, we can remove some contrived 
> representation of access flags present in mainline (that required pulling 
> class version from Class mirrors) and migrate to our simplified system that 
> decodes the uniform representation used by hotspot.

This pull request has now been integrated.

Changeset: a7ecceb9
Author:    Chen Liang <[email protected]>
URL:       
https://git.openjdk.org/valhalla/commit/a7ecceb9bd1a99f0674b76a852cc3ab2c25326a4
Stats:     699 lines in 29 files changed: 376 ins; 252 del; 71 mod

8379559: [lworld] Avoid using new ClassFileFormatVersion for preview access 
flags
8379935: [lworld] Class::accessFlags fails with IAE for non-preview inner 
classes

Reviewed-by: rriggs, phubner

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

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

Reply via email to