Skip to content

Commit

Permalink
8261404: Class.getReflectionFactory() is not thread-safe
Browse files Browse the repository at this point in the history
Backport-of: 905b7639424a0fa80f81f734f6fdae1b5018a14a
  • Loading branch information
Delawen authored and jerboaa committed Jan 29, 2024
1 parent 3432698 commit d7c67fc
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 @@ -3788,12 +3788,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 d7c67fc

@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.