@@ -2518,7 +2518,7 @@ private static class ReflectionData<T> {
2518
2518
2519
2519
// Incremented by the VM on each call to JVM TI RedefineClasses()
2520
2520
// that redefines this class or a superclass.
2521
- private transient volatile int classRedefinedCount = 0 ;
2521
+ private transient volatile int classRedefinedCount ;
2522
2522
2523
2523
// Lazily create and cache ReflectionData
2524
2524
private ReflectionData <T > reflectionData () {
@@ -3331,7 +3331,8 @@ public T[] getEnumConstants() {
3331
3331
* uncloned, cached, and shared by all callers.
3332
3332
*/
3333
3333
T [] getEnumConstantsShared () {
3334
- if (enumConstants == null ) {
3334
+ T [] constants = enumConstants ;
3335
+ if (constants == null ) {
3335
3336
if (!isEnum ()) return null ;
3336
3337
try {
3337
3338
final Method values = getMethod ("values" );
@@ -3344,16 +3345,16 @@ public Void run() {
3344
3345
});
3345
3346
@ SuppressWarnings ("unchecked" )
3346
3347
T [] temporaryConstants = (T [])values .invoke (null );
3347
- enumConstants = temporaryConstants ;
3348
+ enumConstants = constants = temporaryConstants ;
3348
3349
}
3349
3350
// These can happen when users concoct enum-like classes
3350
3351
// that don't comply with the enum spec.
3351
3352
catch (InvocationTargetException | NoSuchMethodException |
3352
3353
IllegalAccessException ex ) { return null ; }
3353
3354
}
3354
- return enumConstants ;
3355
+ return constants ;
3355
3356
}
3356
- private transient volatile T [] enumConstants = null ;
3357
+ private transient volatile T [] enumConstants ;
3357
3358
3358
3359
/**
3359
3360
* Returns a map from simple name to enum constant. This package-private
@@ -3363,19 +3364,21 @@ public Void run() {
3363
3364
* created lazily on first use. Typically it won't ever get created.
3364
3365
*/
3365
3366
Map <String , T > enumConstantDirectory () {
3366
- if (enumConstantDirectory == null ) {
3367
+ Map <String , T > directory = enumConstantDirectory ;
3368
+ if (directory == null ) {
3367
3369
T [] universe = getEnumConstantsShared ();
3368
3370
if (universe == null )
3369
3371
throw new IllegalArgumentException (
3370
3372
getName () + " is not an enum type" );
3371
- Map <String , T > m = new HashMap <>(2 * universe .length );
3372
- for (T constant : universe )
3373
- m .put (((Enum <?>)constant ).name (), constant );
3374
- enumConstantDirectory = m ;
3373
+ directory = new HashMap <>(2 * universe .length );
3374
+ for (T constant : universe ) {
3375
+ directory .put (((Enum <?>)constant ).name (), constant );
3376
+ }
3377
+ enumConstantDirectory = directory ;
3375
3378
}
3376
- return enumConstantDirectory ;
3379
+ return directory ;
3377
3380
}
3378
- private transient volatile Map <String , T > enumConstantDirectory = null ;
3381
+ private transient volatile Map <String , T > enumConstantDirectory ;
3379
3382
3380
3383
/**
3381
3384
* Casts an object to the class or interface represented
0 commit comments