92
92
*/
93
93
@ SuppressWarnings ("doclint:reference" ) // cross-module link
94
94
public 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
+
95
100
/**
96
101
* The access flag {@code ACC_PUBLIC}, corresponding to the source
97
102
* modifier {@link Modifier#PUBLIC public} with a mask value of
98
103
* <code>{@value "0x%04x" Modifier#PUBLIC}</code>.
99
104
*/
100
105
PUBLIC (Modifier .PUBLIC , true ,
101
106
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
+ }
106
114
}),
107
115
108
116
/**
@@ -111,10 +119,13 @@ public enum AccessFlag {
111
119
* value of <code>{@value "0x%04x" Modifier#PRIVATE}</code>.
112
120
*/
113
121
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
+ }
118
129
}),
119
130
120
131
/**
@@ -123,19 +134,28 @@ public enum AccessFlag {
123
134
* value of <code>{@value "0x%04x" Modifier#PROTECTED}</code>.
124
135
*/
125
136
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 ) ?
127
141
Location .SET_FIELD_METHOD :
128
- Location .SET_FIELD_METHOD_INNER_CLASS ;}),
142
+ Location .SET_FIELD_METHOD_INNER_CLASS ;
143
+ }
144
+ }),
129
145
130
146
/**
131
147
* The access flag {@code ACC_STATIC}, corresponding to the source
132
148
* modifier {@link Modifier#STATIC static} with a mask value of
133
149
* <code>{@value "0x%04x" Modifier#STATIC}</code>.
134
150
*/
135
151
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
+ }),
139
159
140
160
/**
141
161
* The access flag {@code ACC_FINAL}, corresponding to the source
@@ -144,13 +164,16 @@ public enum AccessFlag {
144
164
*/
145
165
FINAL (Modifier .FINAL , true ,
146
166
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
+ }
154
177
}
155
178
}),
156
179
@@ -170,19 +193,27 @@ public enum AccessFlag {
170
193
* @see java.lang.module.ModuleDescriptor#isOpen
171
194
*/
172
195
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
+ }),
176
203
177
204
/**
178
205
* The module requires flag {@code ACC_TRANSITIVE} with a mask
179
206
* value of {@code 0x0020}.
180
207
* @see java.lang.module.ModuleDescriptor.Requires.Modifier#TRANSITIVE
181
208
*/
182
209
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
+ }),
186
217
187
218
/**
188
219
* The access flag {@code ACC_SYNCHRONIZED}, corresponding to the
@@ -197,9 +228,13 @@ public enum AccessFlag {
197
228
* @see java.lang.module.ModuleDescriptor.Requires.Modifier#STATIC
198
229
*/
199
230
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
+ }),
203
238
204
239
/**
205
240
* The access flag {@code ACC_VOLATILE}, corresponding to the
@@ -214,9 +249,13 @@ public enum AccessFlag {
214
249
* @see Method#isBridge()
215
250
*/
216
251
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
+ }),
220
259
221
260
/**
222
261
* The access flag {@code ACC_TRANSIENT}, corresponding to the
@@ -231,10 +270,13 @@ public enum AccessFlag {
231
270
* @see Executable#isVarArgs()
232
271
*/
233
272
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
+ }),
238
280
239
281
/**
240
282
* The access flag {@code ACC_NATIVE}, corresponding to the source
@@ -249,9 +291,13 @@ public enum AccessFlag {
249
291
* @see Class#isInterface()
250
292
*/
251
293
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
+ }),
255
301
256
302
/**
257
303
* The access flag {@code ACC_ABSTRACT}, corresponding to the
@@ -260,9 +306,13 @@ public enum AccessFlag {
260
306
*/
261
307
ABSTRACT (Modifier .ABSTRACT , true ,
262
308
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
+ }),
266
316
267
317
/**
268
318
* The access flag {@code ACC_STRICT}, corresponding to the source
@@ -275,11 +325,14 @@ public enum AccessFlag {
275
325
* corresponding to Java SE 1.2 through 16.
276
326
*/
277
327
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
+ }),
283
336
284
337
/**
285
338
* The access flag {@code ACC_SYNTHETIC} with a mask value of
@@ -289,16 +342,19 @@ public enum AccessFlag {
289
342
* @see java.lang.module.ModuleDescriptor.Modifier#SYNTHETIC
290
343
*/
291
344
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
+ }
302
358
}
303
359
}),
304
360
@@ -308,32 +364,43 @@ public enum AccessFlag {
308
364
* @see Class#isAnnotation()
309
365
*/
310
366
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
+ }),
314
374
315
375
/**
316
376
* The access flag {@code ACC_ENUM} with a mask value of
317
377
* <code>{@value "0x%04x" Modifier#ENUM}</code>.
318
378
* @see Class#isEnum()
319
379
*/
320
380
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
+ }),
324
388
325
389
/**
326
390
* The access flag {@code ACC_MANDATED} with a mask value of
327
391
* <code>{@value "0x%04x" Modifier#MANDATED}</code>.
328
392
*/
329
393
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
+ }
337
404
}
338
405
}),
339
406
@@ -342,9 +409,13 @@ public enum AccessFlag {
342
409
* 0x8000}.
343
410
*/
344
411
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
+ })
348
419
;
349
420
350
421
// May want to override toString for a different enum constant ->
0 commit comments