9292 */
9393@ SuppressWarnings ("doclint:reference" ) // cross-module link
9494public enum AccessFlag {
95+ // Note to maintainers: anonymous class instances are used rather
96+ // than lambdas to initialize the functions used for the
97+ // cffvToLocations field to avoid using lambdas too early in JDK
98+ // initialization.
99+
95100 /**
96101 * The access flag {@code ACC_PUBLIC}, corresponding to the source
97102 * modifier {@link Modifier#PUBLIC public} with a mask value of
98103 * <code>{@value "0x%04x" Modifier#PUBLIC}</code>.
99104 */
100105 PUBLIC (Modifier .PUBLIC , true ,
101106 Location .SET_PUBLIC_1 ,
102- cffv -> {
103- return (cffv == ClassFileFormatVersion .RELEASE_0 ) ?
104- Location .SET_CLASS_FIELD_METHOD :
105- Location .SET_PUBLIC_1 ;
107+ new Function <ClassFileFormatVersion , Set <Location >>() {
108+ @ Override
109+ public Set <Location > apply (ClassFileFormatVersion cffv ) {
110+ return (cffv == ClassFileFormatVersion .RELEASE_0 ) ?
111+ Location .SET_CLASS_FIELD_METHOD :
112+ Location .SET_PUBLIC_1 ;
113+ }
106114 }),
107115
108116 /**
@@ -111,10 +119,13 @@ public enum AccessFlag {
111119 * value of <code>{@value "0x%04x" Modifier#PRIVATE}</code>.
112120 */
113121 PRIVATE (Modifier .PRIVATE , true , Location .SET_FIELD_METHOD_INNER_CLASS ,
114- cffv -> {
115- return (cffv == ClassFileFormatVersion .RELEASE_0 ) ?
116- Location .SET_FIELD_METHOD :
117- Location .SET_FIELD_METHOD_INNER_CLASS ;
122+ new Function <ClassFileFormatVersion , Set <Location >>() {
123+ @ Override
124+ public Set <Location > apply (ClassFileFormatVersion cffv ) {
125+ return (cffv == ClassFileFormatVersion .RELEASE_0 ) ?
126+ Location .SET_FIELD_METHOD :
127+ Location .SET_FIELD_METHOD_INNER_CLASS ;
128+ }
118129 }),
119130
120131 /**
@@ -123,19 +134,28 @@ public enum AccessFlag {
123134 * value of <code>{@value "0x%04x" Modifier#PROTECTED}</code>.
124135 */
125136 PROTECTED (Modifier .PROTECTED , true , Location .SET_FIELD_METHOD_INNER_CLASS ,
126- cffv -> {return (cffv == ClassFileFormatVersion .RELEASE_0 ) ?
137+ new Function <ClassFileFormatVersion , Set <Location >>() {
138+ @ Override
139+ public Set <Location > apply (ClassFileFormatVersion cffv ) {
140+ return (cffv == ClassFileFormatVersion .RELEASE_0 ) ?
127141 Location .SET_FIELD_METHOD :
128- Location .SET_FIELD_METHOD_INNER_CLASS ;}),
142+ Location .SET_FIELD_METHOD_INNER_CLASS ;
143+ }
144+ }),
129145
130146 /**
131147 * The access flag {@code ACC_STATIC}, corresponding to the source
132148 * modifier {@link Modifier#STATIC static} with a mask value of
133149 * <code>{@value "0x%04x" Modifier#STATIC}</code>.
134150 */
135151 STATIC (Modifier .STATIC , true , Location .SET_FIELD_METHOD_INNER_CLASS ,
136- cffv -> {return (cffv == ClassFileFormatVersion .RELEASE_0 ) ?
137- Location .SET_FIELD_METHOD :
138- Location .SET_FIELD_METHOD_INNER_CLASS ;}),
152+ new Function <ClassFileFormatVersion , Set <Location >>() {
153+ @ Override
154+ public Set <Location > apply (ClassFileFormatVersion cffv ) {
155+ return (cffv == ClassFileFormatVersion .RELEASE_0 ) ?
156+ Location .SET_FIELD_METHOD :
157+ Location .SET_FIELD_METHOD_INNER_CLASS ;}
158+ }),
139159
140160 /**
141161 * The access flag {@code ACC_FINAL}, corresponding to the source
@@ -144,13 +164,16 @@ public enum AccessFlag {
144164 */
145165 FINAL (Modifier .FINAL , true ,
146166 Location .SET_FINAL_8 ,
147- cffv -> {
148- if (cffv .compareTo (ClassFileFormatVersion .RELEASE_8 ) >= 0 ) {
149- return Location .SET_FINAL_8 ;
150- } else {
151- return (cffv == ClassFileFormatVersion .RELEASE_0 ) ?
152- Location .SET_CLASS_FIELD_METHOD :
153- Location .SET_CLASS_FIELD_METHOD_INNER_CLASS ;
167+ new Function <ClassFileFormatVersion , Set <Location >>() {
168+ @ Override
169+ public Set <Location > apply (ClassFileFormatVersion cffv ) {
170+ if (cffv .compareTo (ClassFileFormatVersion .RELEASE_8 ) >= 0 ) {
171+ return Location .SET_FINAL_8 ;
172+ } else {
173+ return (cffv == ClassFileFormatVersion .RELEASE_0 ) ?
174+ Location .SET_CLASS_FIELD_METHOD :
175+ Location .SET_CLASS_FIELD_METHOD_INNER_CLASS ;
176+ }
154177 }
155178 }),
156179
@@ -170,19 +193,27 @@ public enum AccessFlag {
170193 * @see java.lang.module.ModuleDescriptor#isOpen
171194 */
172195 OPEN (0x0000_0020 , false , Location .SET_MODULE ,
173- cffv -> { return (cffv .compareTo (ClassFileFormatVersion .RELEASE_9 ) >= 0 ) ?
174- Location .SET_MODULE :
175- Location .EMPTY_SET ;}),
196+ new Function <ClassFileFormatVersion , Set <Location >>() {
197+ @ Override
198+ public Set <Location > apply (ClassFileFormatVersion cffv ) {
199+ return (cffv .compareTo (ClassFileFormatVersion .RELEASE_9 ) >= 0 ) ?
200+ Location .SET_MODULE :
201+ Location .EMPTY_SET ;}
202+ }),
176203
177204 /**
178205 * The module requires flag {@code ACC_TRANSITIVE} with a mask
179206 * value of {@code 0x0020}.
180207 * @see java.lang.module.ModuleDescriptor.Requires.Modifier#TRANSITIVE
181208 */
182209 TRANSITIVE (0x0000_0020 , false , Location .SET_MODULE_REQUIRES ,
183- cffv -> {return (cffv .compareTo (ClassFileFormatVersion .RELEASE_9 ) >= 0 ) ?
184- Location .SET_MODULE_REQUIRES :
185- Location .EMPTY_SET ;}),
210+ new Function <ClassFileFormatVersion , Set <Location >>() {
211+ @ Override
212+ public Set <Location > apply (ClassFileFormatVersion cffv ) {
213+ return (cffv .compareTo (ClassFileFormatVersion .RELEASE_9 ) >= 0 ) ?
214+ Location .SET_MODULE_REQUIRES :
215+ Location .EMPTY_SET ;}
216+ }),
186217
187218 /**
188219 * The access flag {@code ACC_SYNCHRONIZED}, corresponding to the
@@ -197,9 +228,13 @@ public enum AccessFlag {
197228 * @see java.lang.module.ModuleDescriptor.Requires.Modifier#STATIC
198229 */
199230 STATIC_PHASE (0x0000_0040 , false , Location .SET_MODULE_REQUIRES ,
200- cffv -> {return (cffv .compareTo (ClassFileFormatVersion .RELEASE_9 ) >= 0 ) ?
201- Location .SET_MODULE_REQUIRES :
202- Location .EMPTY_SET ;}),
231+ new Function <ClassFileFormatVersion , Set <Location >>() {
232+ @ Override
233+ public Set <Location > apply (ClassFileFormatVersion cffv ) {
234+ return (cffv .compareTo (ClassFileFormatVersion .RELEASE_9 ) >= 0 ) ?
235+ Location .SET_MODULE_REQUIRES :
236+ Location .EMPTY_SET ;}
237+ }),
203238
204239 /**
205240 * The access flag {@code ACC_VOLATILE}, corresponding to the
@@ -214,9 +249,13 @@ public enum AccessFlag {
214249 * @see Method#isBridge()
215250 */
216251 BRIDGE (Modifier .BRIDGE , false , Location .SET_METHOD ,
217- cffv -> {return (cffv .compareTo (ClassFileFormatVersion .RELEASE_5 ) >= 0 ) ?
218- Location .SET_METHOD :
219- Location .EMPTY_SET ;}),
252+ new Function <ClassFileFormatVersion , Set <Location >>() {
253+ @ Override
254+ public Set <Location > apply (ClassFileFormatVersion cffv ) {
255+ return (cffv .compareTo (ClassFileFormatVersion .RELEASE_5 ) >= 0 ) ?
256+ Location .SET_METHOD :
257+ Location .EMPTY_SET ;}
258+ }),
220259
221260 /**
222261 * The access flag {@code ACC_TRANSIENT}, corresponding to the
@@ -231,10 +270,13 @@ public enum AccessFlag {
231270 * @see Executable#isVarArgs()
232271 */
233272 VARARGS (Modifier .VARARGS , false , Location .SET_METHOD ,
234- cffv -> {return (cffv .compareTo (ClassFileFormatVersion .RELEASE_5 ) >= 0 ) ?
235- Location .SET_METHOD :
236- Location .EMPTY_SET ;}),
237-
273+ new Function <ClassFileFormatVersion , Set <Location >>() {
274+ @ Override
275+ public Set <Location > apply (ClassFileFormatVersion cffv ) {
276+ return (cffv .compareTo (ClassFileFormatVersion .RELEASE_5 ) >= 0 ) ?
277+ Location .SET_METHOD :
278+ Location .EMPTY_SET ;}
279+ }),
238280
239281 /**
240282 * The access flag {@code ACC_NATIVE}, corresponding to the source
@@ -249,9 +291,13 @@ public enum AccessFlag {
249291 * @see Class#isInterface()
250292 */
251293 INTERFACE (Modifier .INTERFACE , false , Location .SET_CLASS_INNER_CLASS ,
252- cffv -> { return (cffv .compareTo (ClassFileFormatVersion .RELEASE_0 ) == 0 ) ?
253- Location .SET_CLASS :
254- Location .SET_CLASS_INNER_CLASS ;}),
294+ new Function <ClassFileFormatVersion , Set <Location >>() {
295+ @ Override
296+ public Set <Location > apply (ClassFileFormatVersion cffv ) {
297+ return (cffv .compareTo (ClassFileFormatVersion .RELEASE_0 ) == 0 ) ?
298+ Location .SET_CLASS :
299+ Location .SET_CLASS_INNER_CLASS ;}
300+ }),
255301
256302 /**
257303 * The access flag {@code ACC_ABSTRACT}, corresponding to the
@@ -260,9 +306,13 @@ public enum AccessFlag {
260306 */
261307 ABSTRACT (Modifier .ABSTRACT , true ,
262308 Location .SET_CLASS_METHOD_INNER_CLASS ,
263- cffv -> { return (cffv .compareTo (ClassFileFormatVersion .RELEASE_0 ) == 0 ) ?
264- Location .SET_CLASS_METHOD :
265- Location .SET_CLASS_METHOD_INNER_CLASS ;}),
309+ new Function <ClassFileFormatVersion , Set <Location >>() {
310+ @ Override
311+ public Set <Location > apply (ClassFileFormatVersion cffv ) {
312+ return (cffv .compareTo (ClassFileFormatVersion .RELEASE_0 ) == 0 ) ?
313+ Location .SET_CLASS_METHOD :
314+ Location .SET_CLASS_METHOD_INNER_CLASS ;}
315+ }),
266316
267317 /**
268318 * The access flag {@code ACC_STRICT}, corresponding to the source
@@ -275,11 +325,14 @@ public enum AccessFlag {
275325 * corresponding to Java SE 1.2 through 16.
276326 */
277327 STRICT (Modifier .STRICT , true , Location .SET_METHOD ,
278- cffv -> {return (cffv .compareTo (ClassFileFormatVersion .RELEASE_2 ) >= 0 &&
279- cffv .compareTo (ClassFileFormatVersion .RELEASE_16 ) <= 0 ) ?
280- Location .SET_METHOD :
281- Location .EMPTY_SET ;}),
282-
328+ new Function <ClassFileFormatVersion , Set <Location >>() {
329+ @ Override
330+ public Set <Location > apply (ClassFileFormatVersion cffv ) {
331+ return (cffv .compareTo (ClassFileFormatVersion .RELEASE_2 ) >= 0 &&
332+ cffv .compareTo (ClassFileFormatVersion .RELEASE_16 ) <= 0 ) ?
333+ Location .SET_METHOD :
334+ Location .EMPTY_SET ;}
335+ }),
283336
284337 /**
285338 * The access flag {@code ACC_SYNTHETIC} with a mask value of
@@ -289,16 +342,19 @@ public enum AccessFlag {
289342 * @see java.lang.module.ModuleDescriptor.Modifier#SYNTHETIC
290343 */
291344 SYNTHETIC (Modifier .SYNTHETIC , false , Location .SET_SYNTHETIC_9 ,
292- cffv -> {
293- if (cffv .compareTo (ClassFileFormatVersion .RELEASE_9 ) >= 0 )
294- return Location .SET_SYNTHETIC_9 ;
295- else {
296- return
297- switch (cffv ) {
298- case RELEASE_7 -> Location .SET_SYNTHETIC_7 ;
299- case RELEASE_8 -> Location .SET_SYNTHETIC_8 ;
300- default -> Location .EMPTY_SET ;
301- };
345+ new Function <ClassFileFormatVersion , Set <Location >>() {
346+ @ Override
347+ public Set <Location > apply (ClassFileFormatVersion cffv ) {
348+ if (cffv .compareTo (ClassFileFormatVersion .RELEASE_9 ) >= 0 )
349+ return Location .SET_SYNTHETIC_9 ;
350+ else {
351+ return
352+ switch (cffv ) {
353+ case RELEASE_7 -> Location .SET_SYNTHETIC_7 ;
354+ case RELEASE_8 -> Location .SET_SYNTHETIC_8 ;
355+ default -> Location .EMPTY_SET ;
356+ };
357+ }
302358 }
303359 }),
304360
@@ -308,32 +364,43 @@ public enum AccessFlag {
308364 * @see Class#isAnnotation()
309365 */
310366 ANNOTATION (Modifier .ANNOTATION , false , Location .SET_CLASS_INNER_CLASS ,
311- cffv -> {return (cffv .compareTo (ClassFileFormatVersion .RELEASE_5 ) >= 0 ) ?
312- Location .SET_CLASS_INNER_CLASS :
313- Location .EMPTY_SET ;}),
367+ new Function <ClassFileFormatVersion , Set <Location >>() {
368+ @ Override
369+ public Set <Location > apply (ClassFileFormatVersion cffv ) {
370+ return (cffv .compareTo (ClassFileFormatVersion .RELEASE_5 ) >= 0 ) ?
371+ Location .SET_CLASS_INNER_CLASS :
372+ Location .EMPTY_SET ;}
373+ }),
314374
315375 /**
316376 * The access flag {@code ACC_ENUM} with a mask value of
317377 * <code>{@value "0x%04x" Modifier#ENUM}</code>.
318378 * @see Class#isEnum()
319379 */
320380 ENUM (Modifier .ENUM , false , Location .SET_CLASS_FIELD_INNER_CLASS ,
321- cffv -> {return (cffv .compareTo (ClassFileFormatVersion .RELEASE_5 ) >= 0 ) ?
322- Location .SET_CLASS_FIELD_INNER_CLASS :
323- Location .EMPTY_SET ;}),
381+ new Function <ClassFileFormatVersion , Set <Location >>() {
382+ @ Override
383+ public Set <Location > apply (ClassFileFormatVersion cffv ) {
384+ return (cffv .compareTo (ClassFileFormatVersion .RELEASE_5 ) >= 0 ) ?
385+ Location .SET_CLASS_FIELD_INNER_CLASS :
386+ Location .EMPTY_SET ;}
387+ }),
324388
325389 /**
326390 * The access flag {@code ACC_MANDATED} with a mask value of
327391 * <code>{@value "0x%04x" Modifier#MANDATED}</code>.
328392 */
329393 MANDATED (Modifier .MANDATED , false , Location .SET_MANDATED_9 ,
330- cffv -> {
331- if (cffv .compareTo (ClassFileFormatVersion .RELEASE_9 ) >= 0 ) {
332- return Location .SET_MANDATED_9 ;
333- } else {
334- return (cffv == ClassFileFormatVersion .RELEASE_8 ) ?
335- Location .SET_METHOD_PARAM :
336- Location .EMPTY_SET ;
394+ new Function <ClassFileFormatVersion , Set <Location >>() {
395+ @ Override
396+ public Set <Location > apply (ClassFileFormatVersion cffv ) {
397+ if (cffv .compareTo (ClassFileFormatVersion .RELEASE_9 ) >= 0 ) {
398+ return Location .SET_MANDATED_9 ;
399+ } else {
400+ return (cffv == ClassFileFormatVersion .RELEASE_8 ) ?
401+ Location .SET_METHOD_PARAM :
402+ Location .EMPTY_SET ;
403+ }
337404 }
338405 }),
339406
@@ -342,9 +409,13 @@ public enum AccessFlag {
342409 * 0x8000}.
343410 */
344411 MODULE (0x0000_8000 , false , Location .SET_CLASS ,
345- cffv -> {return (cffv .compareTo (ClassFileFormatVersion .RELEASE_9 ) >= 0 ) ?
346- Location .SET_CLASS :
347- Location .EMPTY_SET ;})
412+ new Function <ClassFileFormatVersion , Set <Location >>() {
413+ @ Override
414+ public Set <Location > apply (ClassFileFormatVersion cffv ) {
415+ return (cffv .compareTo (ClassFileFormatVersion .RELEASE_9 ) >= 0 ) ?
416+ Location .SET_CLASS :
417+ Location .EMPTY_SET ;}
418+ })
348419 ;
349420
350421 // May want to override toString for a different enum constant ->
0 commit comments