< prev index next >

test/jdk/java/lang/reflect/AccessFlag/BasicAccessFlagTest.java

Print this page

125     private static void reportError(AccessFlag.Location location,
126                                     AccessFlag accessFlag,
127                                     Integer mask, Set<AccessFlag> value) {
128         System.err.println("Location " + location +
129                            " from " + accessFlag +
130                            " already present for 0x" +
131                            Integer.toHexString(mask) + ": " + value);
132         throw new RuntimeException();
133     }
134 
135     // For each access flag, make sure it is recognized on every kind
136     // of location it can apply to
137     @Test
138     public void testMaskToAccessFlagsPositive() {
139         for (var accessFlag : AccessFlag.values()) {
140             Set<AccessFlag> expectedSet = EnumSet.of(accessFlag);
141             for (var location : accessFlag.locations()) {
142                 Set<AccessFlag> computedSet =
143                     AccessFlag.maskToAccessFlags(accessFlag.mask(), location);
144                 if (!expectedSet.equals(computedSet)) {


145                     throw new RuntimeException("Bad set computation on " +
146                                                accessFlag + ", " + location);
147                 }
148             }
149             for (var cffv : ClassFileFormatVersion.values()) {
150                 for (var location : accessFlag.locations(cffv)) {
151                     Set<AccessFlag> computedSet =
152                             AccessFlag.maskToAccessFlags(accessFlag.mask(), location, cffv);
153                     if (!expectedSet.equals(computedSet)) {
154                         throw new RuntimeException("Bad set computation on " +
155                                 accessFlag + ", " + location);
156                     }
157                 }
158             }
159         }
160         assertEquals(Set.of(AccessFlag.STRICT), AccessFlag.maskToAccessFlags(Modifier.STRICT, AccessFlag.Location.METHOD, ClassFileFormatVersion.RELEASE_8));
161     }
162 
163     @Test
164     public void testMaskToAccessFlagsNegative() {

125     private static void reportError(AccessFlag.Location location,
126                                     AccessFlag accessFlag,
127                                     Integer mask, Set<AccessFlag> value) {
128         System.err.println("Location " + location +
129                            " from " + accessFlag +
130                            " already present for 0x" +
131                            Integer.toHexString(mask) + ": " + value);
132         throw new RuntimeException();
133     }
134 
135     // For each access flag, make sure it is recognized on every kind
136     // of location it can apply to
137     @Test
138     public void testMaskToAccessFlagsPositive() {
139         for (var accessFlag : AccessFlag.values()) {
140             Set<AccessFlag> expectedSet = EnumSet.of(accessFlag);
141             for (var location : accessFlag.locations()) {
142                 Set<AccessFlag> computedSet =
143                     AccessFlag.maskToAccessFlags(accessFlag.mask(), location);
144                 if (!expectedSet.equals(computedSet)) {
145                     System.out.println("expected: " + expectedSet);
146                     System.out.println("computed: " + computedSet);
147                     throw new RuntimeException("Bad set computation on " +
148                                                accessFlag + ", " + location);
149                 }
150             }
151             for (var cffv : ClassFileFormatVersion.values()) {
152                 for (var location : accessFlag.locations(cffv)) {
153                     Set<AccessFlag> computedSet =
154                             AccessFlag.maskToAccessFlags(accessFlag.mask(), location, cffv);
155                     if (!expectedSet.equals(computedSet)) {
156                         throw new RuntimeException("Bad set computation on " +
157                                 accessFlag + ", " + location);
158                     }
159                 }
160             }
161         }
162         assertEquals(Set.of(AccessFlag.STRICT), AccessFlag.maskToAccessFlags(Modifier.STRICT, AccessFlag.Location.METHOD, ClassFileFormatVersion.RELEASE_8));
163     }
164 
165     @Test
166     public void testMaskToAccessFlagsNegative() {
< prev index next >