Solve ReflectPermission Issue in Sandbox Security Policy Model

This commit is contained in:
Kalmesh Sambrani 2020-01-23 15:34:18 +05:30 committed by Juergen Hoeller
parent a2af5a90dc
commit d085577e0a
1 changed files with 9 additions and 1 deletions

View File

@ -336,7 +336,15 @@ public class ReflectUtils {
public static Constructor getConstructor(Class type, Class[] parameterTypes) { public static Constructor getConstructor(Class type, Class[] parameterTypes) {
try { try {
Constructor constructor = type.getDeclaredConstructor(parameterTypes); 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; return constructor;
} }
catch (NoSuchMethodException e) { catch (NoSuchMethodException e) {