Closed as not planned
Closed as not planned
Description
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>>