< prev index next > src/java.base/share/classes/java/lang/reflect/AccessFlag.java
Print this page
* In Java SE 8 and above, the JVM treats the {@code ACC_SUPER}
* flag as set in every class file (JVMS {@jvms 4.1}).
*/
SUPER(0x0000_0020, false, Location.SET_CLASS, null),
/**
* The module flag {@code ACC_OPEN} with a mask value of {@code
* 0x0020}.
* @see java.lang.module.ModuleDescriptor#isOpen
*/
! OPEN(0x0000_0020, false, Location.SET_MODULE,
! new Function<ClassFileFormatVersion, Set<Location>>() {
! @Override
! public Set<Location> apply(ClassFileFormatVersion cffv) {
! return (cffv.compareTo(ClassFileFormatVersion.RELEASE_9) >= 0 ) ?
! Location.SET_MODULE:
! Location.EMPTY_SET;}
! }),
/**
* The module requires flag {@code ACC_TRANSITIVE} with a mask
* value of {@code 0x0020}.
* @see java.lang.module.ModuleDescriptor.Requires.Modifier#TRANSITIVE
* In Java SE 8 and above, the JVM treats the {@code ACC_SUPER}
* flag as set in every class file (JVMS {@jvms 4.1}).
*/
SUPER(0x0000_0020, false, Location.SET_CLASS, null),
+ /**
+ * The access flag {@code ACC_IDENTITY}, corresponding to the
+ * source modifier {@link Modifier#IDENTITY identity}, with a mask
+ * value of <code>{@value "0x%04x" Modifier#IDENTITY}</code>.
+ * @jvms 4.1 -B. Class access and property modifiers
+ */
+ IDENTITY(Modifier.IDENTITY, true, Location.SET_CLASS_INNER_CLASS, null),
+
/**
* The module flag {@code ACC_OPEN} with a mask value of {@code
* 0x0020}.
* @see java.lang.module.ModuleDescriptor#isOpen
*/
! OPEN(0x0000_0020, false, Location.SET_MODULE,
! new Function<ClassFileFormatVersion, Set<Location>>() {
! @Override
! public Set<Location> apply(ClassFileFormatVersion cffv) {
! return (cffv.compareTo(ClassFileFormatVersion.RELEASE_9) >= 0 ) ?
! Location.SET_MODULE:
! Location.EMPTY_SET;}
! }),
/**
* The module requires flag {@code ACC_TRANSITIVE} with a mask
* value of {@code 0x0020}.
* @see java.lang.module.ModuleDescriptor.Requires.Modifier#TRANSITIVE
return (cffv.compareTo(ClassFileFormatVersion.RELEASE_9) >= 0 ) ?
Location.SET_MODULE_REQUIRES:
Location.EMPTY_SET;}
}),
! /**
* The access flag {@code ACC_VOLATILE}, corresponding to the
* source modifier {@link Modifier#VOLATILE volatile}, with a mask
* value of <code>{@value "0x%04x" Modifier#VOLATILE}</code>.
*/
VOLATILE(Modifier.VOLATILE, true, Location.SET_FIELD, null),
-
/**
* The access flag {@code ACC_BRIDGE} with a mask value of
* <code>{@value "0x%04x" Modifier#BRIDGE}</code>
* @see Method#isBridge()
*/
return (cffv.compareTo(ClassFileFormatVersion.RELEASE_9) >= 0 ) ?
Location.SET_MODULE_REQUIRES:
Location.EMPTY_SET;}
}),
! /**
+ * The access flag {@code ACC_VALUE}, corresponding to the
+ * source modifier {@link Modifier#VALUE value}, with a mask
+ * value of <code>{@value "0x%04x" Modifier#VALUE}</code>.
+ * @jvms 4.1 -B. Class access and property modifiers
+ */
+ VALUE(Modifier.VALUE, true, Set.of(Location.CLASS, Location.INNER_CLASS), null),
+
+ /**
* The access flag {@code ACC_VOLATILE}, corresponding to the
* source modifier {@link Modifier#VOLATILE volatile}, with a mask
* value of <code>{@value "0x%04x" Modifier#VOLATILE}</code>.
*/
VOLATILE(Modifier.VOLATILE, true, Location.SET_FIELD, null),
/**
* The access flag {@code ACC_BRIDGE} with a mask value of
* <code>{@value "0x%04x" Modifier#BRIDGE}</code>
* @see Method#isBridge()
*/
* @throws IllegalArgumentException if the mask contains bit
* positions not support for the location in question
*/
public static Set<AccessFlag> maskToAccessFlags(int mask, Location location) {
Set<AccessFlag> result = java.util.EnumSet.noneOf(AccessFlag.class);
for (var accessFlag : LocationToFlags.locationToFlags.get(location)) {
int accessMask = accessFlag.mask();
if ((mask & accessMask) != 0) {
result.add(accessFlag);
! mask = mask & ~accessMask;
}
}
! if (mask != 0) {
throw new IllegalArgumentException("Unmatched bit position 0x" +
! Integer.toHexString(mask) +
" for location " + location);
}
return Collections.unmodifiableSet(result);
}
* @throws IllegalArgumentException if the mask contains bit
* positions not support for the location in question
*/
public static Set<AccessFlag> maskToAccessFlags(int mask, Location location) {
Set<AccessFlag> result = java.util.EnumSet.noneOf(AccessFlag.class);
+ int unmatchedFlags = mask;
for (var accessFlag : LocationToFlags.locationToFlags.get(location)) {
int accessMask = accessFlag.mask();
if ((mask & accessMask) != 0) {
result.add(accessFlag);
! unmatchedFlags = unmatchedFlags & ~accessMask;
}
}
! if (unmatchedFlags != 0) {
throw new IllegalArgumentException("Unmatched bit position 0x" +
! Integer.toHexString(unmatchedFlags) +
" for location " + location);
}
return Collections.unmodifiableSet(result);
}
}
private static class LocationToFlags {
private static Map<Location, Set<AccessFlag>> locationToFlags =
Map.ofEntries(entry(Location.CLASS,
! Set.of(PUBLIC, FINAL, SUPER,
INTERFACE, ABSTRACT,
SYNTHETIC, ANNOTATION,
ENUM, AccessFlag.MODULE)),
entry(Location.FIELD,
Set.of(PUBLIC, PRIVATE, PROTECTED,
}
private static class LocationToFlags {
private static Map<Location, Set<AccessFlag>> locationToFlags =
Map.ofEntries(entry(Location.CLASS,
! Set.of(PUBLIC, FINAL, SUPER, IDENTITY, VALUE,
INTERFACE, ABSTRACT,
SYNTHETIC, ANNOTATION,
ENUM, AccessFlag.MODULE)),
entry(Location.FIELD,
Set.of(PUBLIC, PRIVATE, PROTECTED,
Set.of(PUBLIC, PRIVATE, PROTECTED,
STATIC, FINAL, SYNCHRONIZED,
BRIDGE, VARARGS, NATIVE,
ABSTRACT, STRICT, SYNTHETIC)),
entry(Location.INNER_CLASS,
! Set.of(PUBLIC, PRIVATE, PROTECTED,
STATIC, FINAL, INTERFACE, ABSTRACT,
SYNTHETIC, ANNOTATION, ENUM)),
entry(Location.METHOD_PARAMETER,
Set.of(FINAL, SYNTHETIC, MANDATED)),
entry(Location.MODULE,
Set.of(PUBLIC, PRIVATE, PROTECTED,
STATIC, FINAL, SYNCHRONIZED,
BRIDGE, VARARGS, NATIVE,
ABSTRACT, STRICT, SYNTHETIC)),
entry(Location.INNER_CLASS,
! Set.of(PUBLIC, PRIVATE, PROTECTED, IDENTITY, VALUE,
STATIC, FINAL, INTERFACE, ABSTRACT,
SYNTHETIC, ANNOTATION, ENUM)),
entry(Location.METHOD_PARAMETER,
Set.of(FINAL, SYNTHETIC, MANDATED)),
entry(Location.MODULE,
< prev index next >