-
CSR
-
Resolution: Unresolved
-
P3
-
None
-
behavioral
-
low
-
Users using `AccessFlag.maskToAccessFlag` to parse ACC_STRICT from methods will now fail. They must use the ClassFileFormatVersion-aware version instead.
-
Java API
-
SE
Summary
The AccessFlags for classes, methods, constructors and fields should reflect the access flags specified for the class file format version.
Problem
The accessFlags()
methods added (in JDK 20, the current release) to java.lang.Class, java.lang.reflect.Executable, and java.lang.reflect.Field are silent about the dependency of the access flags on the class file format version.
For current and past class file format versions there are few significant variations but future changes are anticipated that change the meaning of some access flag mask bits. One example is the STRICTFP access flag that only applies to releases 2 through 16.
Solution
The accessFlags()
methods should mention that the access flags returned are those applicable to the class file format version of the class.
The existing AccessFlag.Locations
API already contains information about the locations that are applicable to a class file format version.
That information should be used to construct the set of AccessFlags returned.
A method is added to AccessFlag
that returns the applicable flags for a particular mask, Location, and class file format version:
Set<AccessFlags> maskToAccessFlags(int mask, Location, ClassFileFormatVersion cffv)
Specification
java.lang.reflect.AccessFlag additional method:
/**
* {@return an unmodifiable set of access flags for the given mask value
* appropriate for the location for the class file format}
*
* @param mask bit mask of access flags
* @param location context to interpret mask value
* @param cffv the class file format to interpret mask value
* @throws IllegalArgumentException if the mask contains bit
* positions not defined for the location for the class file format
* @throws NullPointerException if {@code location} or {@code cffv} is {@code null}
*/
public static Set<AccessFlag> maskToAccessFlags(int mask, Location location, ClassFileFormatVersion cffv) {
Also for the 2-arg version, "positions not supported" becomes "positions not defined" as shown here; a minor change.
- csr of
-
JDK-8297271 AccessFlag.maskToAccessFlags should be specific to class file version
-
- Open
-
- relates to
-
JDK-8281660 Better modeling of access flags in core reflection
-
- Closed
-
-
JDK-8347626 Provide valid flags and mask in AccessFlag.Location
-
- Proposed
-