JDK-8337219 : AccessFlags factories do not require necessary arguments
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang.classfile
  • Affected Version: 24
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2024-07-25
  • Updated: 2024-08-09
  • Resolved: 2024-07-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 24
24 b09Fixed
Related Reports
Blocks :  
CSR :  
Description
AccessFlags is an object modeling access flag as a classfile element. It is essentially an integer bit mask, bound with a location to allow specific parsing.

However, this bit mask is version specific too. For example, pre-valhalla class files may optionally have the ACC_SUPER bit set for no impact; but once valhalla arrives, it will become ACC_IDENTITY where non-set bit would mean value classes. However, we still want to interpret pre-valhalla classes without this bit set as identity.

As a result, the current `AccessFlags.ofClass` `AccessFlags.ofMethod` `AccessFlags.ofField` methods become problematic if we want to support version-specific parsing, as it's not always proper to assume a latest class file version.

The proposed action is to remove the 6 `ofXxx` factory methods, making `AccessFlags` more similar to bytecode `Label` or `BootstrapMethodsAttribute`, that the creation will be through `withFlags` methods on respective builders. These builders can capture ClassFile versions from context, and thus correctly validate/parse/interpret access flags, which we can enhance in the future.
Comments
Changeset: 93c19ac7 Branch: master Author: Chen Liang <liach@openjdk.org> Date: 2024-07-30 17:41:49 +0000 URL: https://git.openjdk.org/jdk/commit/93c19ac73c2feb8d6191bc5da98b4a9c8e2b5590
30-07-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/20341 Date: 2024-07-25 23:11:15 +0000
25-07-2024