Java 作为参数传递的泛型的Jackson映射失败

Java 作为参数传递的泛型的Jackson映射失败,java,rest,generics,jackson,Java,Rest,Generics,Jackson,我有一个通用的api来从RESTAPI中获取不同的实体。下面是一个获取Groovy实体列表的方法 class CommonRestApi<T>{ CommonRestApi(){ } .... List<T> getEntities(Class<T> clazz) { ClientResponse response = some_rest_get //works fine T[] entities if (respon

我有一个通用的api来从RESTAPI中获取不同的实体。下面是一个获取Groovy实体列表的方法

class CommonRestApi<T>{

CommonRestApi(){        
}
....
List<T> getEntities(Class<T> clazz) {
    ClientResponse response = some_rest_get //works fine
    T[] entities
    if (response.status == 200) {
        try{
            GenericType<ResponseWrapper<T[]>> type = new GenericType<ResponseWrapper<T[]>>(){} //here is error

            entities = response.getEntity(type).getData()
        }catch(Exception e){
            log.debug e.getMessage()
        }
    }
    else {
        log.debug("Status Code: " + response.status)
    }
    return Arrays.asList(entities)
}
}
在这里,RESTAPI成功地返回数据,但到pojo的映射不起作用。错误消息只是:null。有人能告诉我这是否可能吗。如果是,请给我一些指导。
注意:常见的API类在groovy中,我认为问题在于不能用泛型实例化某些东西

new GenericType<ResponseWrapper<T[]>>(){}

这将失败。类型T被编译器完全删除,并且在运行时不存在。

-1不同之处在于实例化GenericType不涉及数组创建,new T[10]就是这样做的。您尝试将类型T与new GenericType{}一起使用,但这只能与具体的泛型类型参数一起使用。T在哪里声明?我添加了类定义。请现在检查。
 commonRestApi.getEntities(MyDomain.class)
new GenericType<ResponseWrapper<T[]>>(){}
new T[10];