8261404: Class.getReflectionFactory() is not thread-safe

Reviewed-by: rriggs, mchung
This commit is contained in:
liach 2021-12-17 22:23:33 +00:00 committed by Mandy Chung
parent 022e4f0f1c
commit 905b763942

@ -3820,12 +3820,13 @@ public final class Class<T> implements java.io.Serializable,
// Fetches the factory for reflective objects
@SuppressWarnings("removal")
private static ReflectionFactory getReflectionFactory() {
if (reflectionFactory == null) {
reflectionFactory =
java.security.AccessController.doPrivileged
(new ReflectionFactory.GetReflectionFactoryAction());
var factory = reflectionFactory;
if (factory != null) {
return factory;
}
return reflectionFactory;
return reflectionFactory =
java.security.AccessController.doPrivileged
(new ReflectionFactory.GetReflectionFactoryAction());
}
private static ReflectionFactory reflectionFactory;