Skip to content

Commit 7e783dd

Browse files
committed
Delete temporary MethodParameterFactory solution
SPR-14055 introduced first-class support for the Java 8 Parameter API. This commit therefore replaces the MethodParameterFactory with use of the new SynthesizingMethodParameter.forParameter(Parameter) factory method. Issue: SPR-13575
1 parent 862fb2a commit 7e783dd

File tree

2 files changed

+5
-111
lines changed

2 files changed

+5
-111
lines changed

spring-test/src/main/java/org/springframework/test/context/junit/jupiter/MethodParameterFactory.java

Lines changed: 0 additions & 98 deletions
This file was deleted.

spring-test/src/main/java/org/springframework/test/context/junit/jupiter/ParameterAutowireUtils.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import java.lang.annotation.Annotation;
2020
import java.lang.reflect.AnnotatedElement;
21-
import java.lang.reflect.Method;
2221
import java.lang.reflect.Parameter;
2322
import java.util.Optional;
2423

@@ -31,13 +30,13 @@
3130
import org.springframework.context.ApplicationContext;
3231
import org.springframework.core.MethodParameter;
3332
import org.springframework.core.annotation.AnnotatedElementUtils;
33+
import org.springframework.core.annotation.SynthesizingMethodParameter;
3434

3535
/**
3636
* Collection of utilities related to autowiring of individual method parameters.
3737
*
3838
* @author Sam Brannen
3939
* @since 5.0
40-
* @see MethodParameterFactory
4140
* @see #isAutowirable(Parameter)
4241
* @see #resolveDependency(Parameter, Class, ApplicationContext)
4342
*/
@@ -86,25 +85,18 @@ static boolean isAutowirable(Parameter parameter) {
8685
* @throws BeansException if dependency resolution failed
8786
* @see #isAutowirable(Parameter)
8887
* @see Autowired#required
89-
* @see MethodParameterFactory#createSynthesizingMethodParameter(Parameter)
88+
* @see SynthesizingMethodParameter#forParameter(Parameter)
9089
* @see AutowireCapableBeanFactory#resolveDependency(DependencyDescriptor, String)
9190
*/
92-
static Object resolveDependency(Parameter parameter, Class<?> containingClass,
93-
ApplicationContext applicationContext) {
94-
91+
static Object resolveDependency(Parameter parameter, Class<?> containingClass, ApplicationContext applicationContext) {
9592
boolean required = findMergedAnnotation(parameter, Autowired.class).map(Autowired::required).orElse(true);
96-
MethodParameter methodParameter = (parameter.getDeclaringExecutable() instanceof Method
97-
? MethodParameterFactory.createSynthesizingMethodParameter(parameter)
98-
: MethodParameterFactory.createMethodParameter(parameter));
93+
MethodParameter methodParameter = SynthesizingMethodParameter.forParameter(parameter);
9994
DependencyDescriptor descriptor = new DependencyDescriptor(methodParameter, required);
10095
descriptor.setContainingClass(containingClass);
101-
10296
return applicationContext.getAutowireCapableBeanFactory().resolveDependency(descriptor, null);
10397
}
10498

105-
private static <A extends Annotation> Optional<A> findMergedAnnotation(AnnotatedElement element,
106-
Class<A> annotationType) {
107-
99+
private static <A extends Annotation> Optional<A> findMergedAnnotation(AnnotatedElement element, Class<A> annotationType) {
108100
return Optional.ofNullable(AnnotatedElementUtils.findMergedAnnotation(element, annotationType));
109101
}
110102

0 commit comments

Comments
 (0)