fix(ConstructorLibrary): prevent AccessControlException by using `AccessController.doPrivilaged`
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
@@ -227,6 +229,8 @@ public T construct() {
return () -> rawTypeCreator.createInstance(type);
}
+ // TODO remove using `AccessController.doPrivileged`
+ return AccessController.doPrivileged((PrivilegedAction<ObjectConstructor<T>>) ()-> {
ObjectConstructor<T> defaultConstructor = newNoArgConstructor(rawType);
if (defaultConstructor != null) {
return defaultConstructor;
@@ -238,6 +242,7 @@ public T construct() {
}
return newUnsafeAllocator(typeInfo);
+ });
}
@Override
