我想使用 JavaGenerics特性来实现一个通用的功能。但是我不知道如何java.lang.reflect.Type为自定义类对象获取对象。以下是我想从给定类名中获取 Type 并将其传递ProcessedResult<T>给 replace 的情况T:
String className = getClassName();
Class clazz = Class.forName(className);
Type type = null;
ProcessedResult<T> result = new ProcessedResult<T>();
我尝试使用ProductModel.class.getGenericSuperclass(),但作为它的名称,它只返回其超类的类型。
有人可以帮我吗?谢谢。