简短的答案是,无法找到Java中泛型类型参数的运行时类型。我建议阅读Java教程中有关类型擦除的章节以获取更多详细信息。
一个流行的解决方案是Class将type参数的传递给泛型类型的构造函数,例如
class Foo<T> { final Class<T> typeParameterClass; public Foo(Class<T> typeParameterClass) { this.typeParameterClass = typeParameterClass; } public void bar() { // you can access the typeParameterClass here and do whatever you like }}


