Skip to content

GenericTypeResolver.resolveType() should resolve ParameterizedType recursively #24963

Closed as not planned
@quaff

Description

@quaff
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.List;
import org.springframework.core.GenericTypeResolver;

public class Main {
	public interface Parent<T> {
		T m1();
		List<T> m2();
		List<List<T>> m3();
	}
	public interface Child extends Parent<String> {
	}
	public static void main(String[] args) {
		for (Method m : Parent.class.getMethods()) {
			Type type = m.getGenericReturnType();
			type = GenericTypeResolver.resolveType(type, Child.class);
			System.out.println("method " + m.getName() + "() will return " + type);
		}
	}
}

will print

method m3() will return java.util.List<java.util.List<T>>
method m1() will return class java.lang.String
method m2() will return java.util.List<java.lang.String>

The expected type for m3 should be java.util.List<java.util.List<String>>

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)status: supersededAn issue that has been superseded by anothertype: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions