mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 16:39:29 +00:00
Delegate to ReflectionUtils.accessibleConstructor
This commit is contained in:
+5
-5
@@ -130,15 +130,14 @@ public class ReflectiveRuntimeHintsRegistrar {
|
||||
|
||||
private ReflectiveProcessor instantiateClass(Class<? extends ReflectiveProcessor> type) {
|
||||
try {
|
||||
Constructor<? extends ReflectiveProcessor> constructor = type.getDeclaredConstructor();
|
||||
ReflectionUtils.makeAccessible(constructor);
|
||||
return constructor.newInstance();
|
||||
return ReflectionUtils.accessibleConstructor(type).newInstance();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new IllegalStateException("Failed to instantiate " + type, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class DelegatingReflectiveProcessor implements ReflectiveProcessor {
|
||||
|
||||
private final Iterable<ReflectiveProcessor> processors;
|
||||
@@ -151,9 +150,10 @@ public class ReflectiveRuntimeHintsRegistrar {
|
||||
public void registerReflectionHints(ReflectionHints hints, AnnotatedElement element) {
|
||||
this.processors.forEach(processor -> processor.registerReflectionHints(hints, element));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private record Entry(AnnotatedElement element, ReflectiveProcessor processor) {}
|
||||
|
||||
private record Entry(AnnotatedElement element, ReflectiveProcessor processor) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-4
@@ -18,7 +18,6 @@ package org.springframework.core.io.support;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.net.SocketException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
@@ -147,9 +146,7 @@ public class PropertySourceProcessor {
|
||||
|
||||
private static PropertySourceFactory instantiateClass(Class<? extends PropertySourceFactory> type) {
|
||||
try {
|
||||
Constructor<? extends PropertySourceFactory> constructor = type.getDeclaredConstructor();
|
||||
ReflectionUtils.makeAccessible(constructor);
|
||||
return constructor.newInstance();
|
||||
return ReflectionUtils.accessibleConstructor(type).newInstance();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new IllegalStateException("Failed to instantiate " + type, ex);
|
||||
|
||||
Reference in New Issue
Block a user