Solve ReflectPermission Issue in Sandbox Security Policy Model
This commit is contained in:
parent
a2af5a90dc
commit
d085577e0a
|
|
@ -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) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue