< prev index next >

src/java.base/share/classes/java/lang/reflect/AccessFlag.java

Print this page
@@ -186,23 +186,31 @@
       * 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;}
-              }),
+     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

@@ -235,17 +243,24 @@
                           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()
       */

@@ -488,20 +503,21 @@
       * @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);
-                 mask = mask & ~accessMask;
+                 unmatchedFlags = unmatchedFlags & ~accessMask;
              }
          }
-         if (mask != 0) {
+         if (unmatchedFlags != 0) {
              throw new IllegalArgumentException("Unmatched bit position 0x" +
-                                                Integer.toHexString(mask) +
+                                                Integer.toHexString(unmatchedFlags) +
                                                 " for location " + location);
          }
          return Collections.unmodifiableSet(result);
      }
  

@@ -621,11 +637,11 @@
      }
  
      private static class LocationToFlags {
          private static Map<Location, Set<AccessFlag>> locationToFlags =
              Map.ofEntries(entry(Location.CLASS,
-                                 Set.of(PUBLIC, FINAL, SUPER,
+                                 Set.of(PUBLIC, FINAL, SUPER, IDENTITY, VALUE,
                                         INTERFACE, ABSTRACT,
                                         SYNTHETIC, ANNOTATION,
                                         ENUM, AccessFlag.MODULE)),
                            entry(Location.FIELD,
                                  Set.of(PUBLIC, PRIVATE, PROTECTED,

@@ -635,11 +651,11 @@
                                  Set.of(PUBLIC, PRIVATE, PROTECTED,
                                         STATIC, FINAL, SYNCHRONIZED,
                                         BRIDGE, VARARGS, NATIVE,
                                         ABSTRACT, STRICT, SYNTHETIC)),
                            entry(Location.INNER_CLASS,
-                                 Set.of(PUBLIC, PRIVATE, PROTECTED,
+                                 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 >