Browse Source

Solve ReflectPermission issue in sandbox security policy model for CGLIB

Closes gh-24420
pull/26383/head
Juergen Hoeller 5 years ago
parent
commit
1b50ca6bd3
  1. 10
      spring-core/src/main/java/org/springframework/cglib/core/ReflectUtils.java

10
spring-core/src/main/java/org/springframework/cglib/core/ReflectUtils.java

@ -336,7 +336,15 @@ public class ReflectUtils { @@ -336,7 +336,15 @@ public class ReflectUtils {
public static Constructor getConstructor(Class type, Class[] parameterTypes) {
try {
Constructor constructor = type.getDeclaredConstructor(parameterTypes);
constructor.setAccessible(true);
if (System.getSecurityManager() != null) {
AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
constructor.setAccessible(true);
return null;
});
}
else {
constructor.setAccessible(true);
}
return constructor;
}
catch (NoSuchMethodException e) {

Loading…
Cancel
Save