Skip to content

Commit

Permalink
8261404: Class.getReflectionFactory() is not thread-safe
Browse files Browse the repository at this point in the history
Reviewed-by: rriggs, mchung
  • Loading branch information
liach authored and Mandy Chung committed Dec 17, 2021
1 parent 022e4f0 commit 905b763
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/java.base/share/classes/java/lang/Class.java
Original file line number Diff line number Diff line change
Expand Up @@ -3820,12 +3820,13 @@ public boolean isRecord() {
// 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;

Expand Down

1 comment on commit 905b763

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.