Solve ReflectPermission issue in sandbox security policy model for CGLIB

Closes gh-24420
This commit is contained in:
Juergen Hoeller
2020-01-28 21:19:15 +01:00
parent 6bae759349
commit 1b50ca6bd3

View File

@@ -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) {