How To Instantiate a java.util.ArrayList with Generic Class Using Reflection? I am writing a method that sets java.util.List on target object. A target object and a generic
Generics is largely a compile time feature. What you are trying to do is the same as
public static void initializeList(Object targetObject, PropertyDescriptor prop, String gtype) { prop.getWriteMethod().invoke(targetObject, new ArrayList()); }
Note: This could change with Types in Java 7.