- How do I build a Java type object at runtime from a generic type definition and runtime type parameters?
- class Foo<T> {
- public T bar;
- }
- class Foo<T> {
- Class<T> clazz;
- public Foo(Class<T> c) {
- clazz = c;
- }
- public T bar {
- return clazz.newInstance();
- }
- }
- public class JsonWrapper {
- private String className;
- private String json; // the output of the gson.toJson() method
- }