diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java index c808a8154124..4825563735ff 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java @@ -21,8 +21,6 @@ import java.io.Serializable; import java.lang.annotation.Annotation; import java.lang.reflect.Field; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; import java.util.Map; import java.util.Optional; @@ -365,23 +363,8 @@ public String getDependencyName() { public Class getDependencyType() { if (this.field != null) { if (this.nestingLevel > 1) { - Type type = this.field.getGenericType(); - for (int i = 2; i <= this.nestingLevel; i++) { - if (type instanceof ParameterizedType) { - Type[] args = ((ParameterizedType) type).getActualTypeArguments(); - type = args[args.length - 1]; - } - } - if (type instanceof Class) { - return (Class) type; - } - else if (type instanceof ParameterizedType) { - Type arg = ((ParameterizedType) type).getRawType(); - if (arg instanceof Class) { - return (Class) arg; - } - } - return Object.class; + Class clazz = getResolvableType().getRawClass(); + return (clazz != null ? clazz : Object.class); } else { return this.field.getType();