@@ -0,0 +1,1764 @@
+package com.googlecode.gentyref;%0A%0Aimport java.lang.reflect.Method;%0Aimport java.lang.reflect.Type;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport junit.framework.TestCase;%0A%0A/**%0A * Sample in the form of a JUnit test, to show gentyref solves the problem on%0A * http://stackoverflow.com/questions/182872/%0A * %0A * @author Wouter Coekaerts %3Cwouter@coekaerts.be%3E%0A */%0Apublic class StackoverflowQ182872Test extends TestCase %7B%0A%09private static Type LIST_OF_STRING = new TypeToken%3CList%3CString%3E%3E()%7B%7D.getType();%0A%09%0A%09public static class StringList extends ArrayList%3CString%3E %7B%7D%0A%0A%09public List%3CString%3E method1() %7Breturn null;%7D%0A%09public ArrayList%3CString%3E method2() %7Breturn null;%7D%0A%09public StringList method3() %7Breturn null;%7D%0A%09interface Parameterized%3CT extends StringList%3E %7B%0A%09%09T method4();%0A%09%7D%0A%09interface Parameterized2%3CT%3E %7B%0A%09%09T method5();%0A%09%7D%0A%09interface Parameterized2ListString extends Parameterized2%3CList%3CString%3E%3E %7B%0A%09%7D%0A%09%0A%09public boolean returnTypeExtendsListOfString(Class%3C?%3E clazz, String methodName) throws NoSuchMethodException %7B%0A%09%09Method method = clazz.getMethod(methodName);%0A%09%09Type returnType = GenericTypeReflector.getExactReturnType(method, clazz); // needed for method5, else the return type is just %22T%22 %0A%09%09return GenericTypeReflector.isSuperType(LIST_OF_STRING, returnType);%0A%09%7D%0A%09%0A%09public void testIt() throws NoSuchMethodException %7B%0A%09%09assertTrue(returnTypeExtendsListOfString(StackoverflowQ182872Test.class, %22method1%22));%0A%09%09assertTrue(returnTypeExtendsListOfString(StackoverflowQ182872Test.class, %22method2%22));%0A%09%09assertTrue(returnTypeExtendsListOfString(StackoverflowQ182872Test.class, %22method3%22));%0A%09%09assertTrue(returnTypeExtendsListOfString(Parameterized.class, %22method4%22));%0A%09%09assertTrue(returnTypeExtendsListOfString(Parameterized2ListString.class, %22method5%22));%0A%09%7D%0A%7D%0A

Add test sample for question 182872 on stackoverflow.com