Creating a Type object corresponding to a generic type
- by Alexey Romanov
In Java, how can I construct a Type object for Map<String, String>?
System.out.println(Map<String, String>.class);
doesn't compile. One workaround I can think of is
private Map<String, String> dummy() { throw new Error(); }
Type mapStringString = Class.forName("ThisClass").getMethod("dummy", null).getGenericReturnType();
Is…