The ParameterizedType implementation returned by getGenericParameterTypes does not override toString, so printing out one these beasts yields no useful information. The following program illustrates the problem:
import java.util.*;
import java.lang.reflect.*;
public class Junk {
public static void main(String[] args) throws Exception {
System.out.println(Junk.class.getMethod("foo", List.class).
getGenericParameterTypes()[0]);
}
public void foo(List<String> dogs) {}
}
Running this program prints:
sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl@1a758cb
import java.util.*;
import java.lang.reflect.*;
public class Junk {
public static void main(String[] args) throws Exception {
System.out.println(Junk.class.getMethod("foo", List.class).
getGenericParameterTypes()[0]);
}
public void foo(List<String> dogs) {}
}
Running this program prints:
sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl@1a758cb
- duplicates
-
JDK-5015676 (reflect) Concrete Type classes could define toString()
- Resolved