Skip to content

Commit 1b50ca6

Browse files
committed
Solve ReflectPermission issue in sandbox security policy model for CGLIB
Closes gh-24420
1 parent 6bae759 commit 1b50ca6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,15 @@ public static Object newInstance(final Constructor cstruct, final Object[] args)
336336
public static Constructor getConstructor(Class type, Class[] parameterTypes) {
337337
try {
338338
Constructor constructor = type.getDeclaredConstructor(parameterTypes);
339-
constructor.setAccessible(true);
339+
if (System.getSecurityManager() != null) {
340+
AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
341+
constructor.setAccessible(true);
342+
return null;
343+
});
344+
}
345+
else {
346+
constructor.setAccessible(true);
347+
}
340348
return constructor;
341349
}
342350
catch (NoSuchMethodException e) {

0 commit comments

Comments
 (0)