Skip to content

Commit aa525cc

Browse files
committed
Delegate to ReflectionUtils.accessibleConstructor
1 parent 00399dc commit aa525cc

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

spring-core/src/main/java/org/springframework/aot/hint/annotation/ReflectiveRuntimeHintsRegistrar.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,14 @@ private Entry createEntry(AnnotatedElement element) {
130130

131131
private ReflectiveProcessor instantiateClass(Class<? extends ReflectiveProcessor> type) {
132132
try {
133-
Constructor<? extends ReflectiveProcessor> constructor = type.getDeclaredConstructor();
134-
ReflectionUtils.makeAccessible(constructor);
135-
return constructor.newInstance();
133+
return ReflectionUtils.accessibleConstructor(type).newInstance();
136134
}
137135
catch (Exception ex) {
138136
throw new IllegalStateException("Failed to instantiate " + type, ex);
139137
}
140138
}
141139

140+
142141
private static class DelegatingReflectiveProcessor implements ReflectiveProcessor {
143142

144143
private final Iterable<ReflectiveProcessor> processors;
@@ -151,9 +150,10 @@ private static class DelegatingReflectiveProcessor implements ReflectiveProcesso
151150
public void registerReflectionHints(ReflectionHints hints, AnnotatedElement element) {
152151
this.processors.forEach(processor -> processor.registerReflectionHints(hints, element));
153152
}
154-
155153
}
156154

157-
private record Entry(AnnotatedElement element, ReflectiveProcessor processor) {}
155+
156+
private record Entry(AnnotatedElement element, ReflectiveProcessor processor) {
157+
}
158158

159159
}

spring-core/src/main/java/org/springframework/core/io/support/PropertySourceProcessor.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import java.io.FileNotFoundException;
2020
import java.io.IOException;
21-
import java.lang.reflect.Constructor;
2221
import java.net.SocketException;
2322
import java.net.UnknownHostException;
2423
import java.util.ArrayList;
@@ -147,9 +146,7 @@ private void addPropertySource(PropertySource<?> propertySource) {
147146

148147
private static PropertySourceFactory instantiateClass(Class<? extends PropertySourceFactory> type) {
149148
try {
150-
Constructor<? extends PropertySourceFactory> constructor = type.getDeclaredConstructor();
151-
ReflectionUtils.makeAccessible(constructor);
152-
return constructor.newInstance();
149+
return ReflectionUtils.accessibleConstructor(type).newInstance();
153150
}
154151
catch (Exception ex) {
155152
throw new IllegalStateException("Failed to instantiate " + type, ex);

0 commit comments

Comments
 (0)