diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/InjectionPoint.java b/spring-beans/src/main/java/org/springframework/beans/factory/InjectionPoint.java index eed896e1b4f0..74954042a329 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/InjectionPoint.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/InjectionPoint.java @@ -48,6 +48,8 @@ public class InjectionPoint { @Nullable private volatile Annotation[] fieldAnnotations; + @Nullable + private volatile Annotation[] methodParameterAnnotations; /** * Create an injection point descriptor for a method or constructor parameter. @@ -76,6 +78,7 @@ protected InjectionPoint(InjectionPoint original) { new MethodParameter(original.methodParameter) : null); this.field = original.field; this.fieldAnnotations = original.fieldAnnotations; + this.methodParameterAnnotations = original.methodParameterAnnotations; } /** @@ -129,7 +132,13 @@ public Annotation[] getAnnotations() { return fieldAnnotations; } else { - return obtainMethodParameter().getParameterAnnotations(); + Annotation[] methodParameterAnnotations = this.methodParameterAnnotations; + if (methodParameterAnnotations == null) { + methodParameterAnnotations = + obtainMethodParameter().getParameterAnnotations(); + this.methodParameterAnnotations = methodParameterAnnotations; + } + return methodParameterAnnotations; } } diff --git a/spring-core/src/main/java/org/springframework/util/MethodInvoker.java b/spring-core/src/main/java/org/springframework/util/MethodInvoker.java index b3e0c5554806..153d517f148a 100644 --- a/spring-core/src/main/java/org/springframework/util/MethodInvoker.java +++ b/spring-core/src/main/java/org/springframework/util/MethodInvoker.java @@ -155,7 +155,8 @@ public Object[] getArguments() { * @see #invoke */ public void prepare() throws ClassNotFoundException, NoSuchMethodException { - if (this.staticMethod != null) { + Class targetClass = getTargetClass(); + if (targetClass == null && this.staticMethod != null) { int lastDotIndex = this.staticMethod.lastIndexOf('.'); if (lastDotIndex == -1 || lastDotIndex == this.staticMethod.length()) { throw new IllegalArgumentException( @@ -164,11 +165,12 @@ public void prepare() throws ClassNotFoundException, NoSuchMethodException { } String className = this.staticMethod.substring(0, lastDotIndex); String methodName = this.staticMethod.substring(lastDotIndex + 1); - this.targetClass = resolveClassName(className); + targetClass = resolveClassName(className); + this.targetClass = targetClass; this.targetMethod = methodName; + } - Class targetClass = getTargetClass(); String targetMethod = getTargetMethod(); Assert.notNull(targetClass, "Either 'targetClass' or 'targetObject' is required"); Assert.notNull(targetMethod, "Property 'targetMethod' is required");