Generics 将代理强制转换为泛型类型时出现问题

Generics 将代理强制转换为泛型类型时出现问题,generics,interface,proxy,casting,Generics,Interface,Proxy,Casting,公共类调用代理实现调用处理程序{ public InvocationProxy(T t) { } public static <T> T makeProxy(T t) { try { Object result = t.getClass().newInstance(); return (T) Proxy.newProxyInstance( ClassLoader.getSystemClassLoa

公共类调用代理实现调用处理程序{

public InvocationProxy(T t) {
 
}

public static <T> T makeProxy(T t) {
    try {
        Object result = t.getClass().newInstance();
        return (T) Proxy.newProxyInstance(
                     ClassLoader.getSystemClassLoader(), 
                     new Class[] {t.getClass().getInterfaces(),
                     new InvocationProxy<T>(t)
        );
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}

public static void main(String[] args) {
    List<Integer> l1 = InvocationProxy.makeProxy(new ArrayList<>());
    l1.add(num1);
    l1.add(num2);
    l1.add(num3);
    .
    .
    .
    or anything else
}
公共调用代理(T){
}
公共静态T生成代理(T){
试一试{
对象结果=t.getClass().newInstance();
return(T)Proxy.newProxyInstance(
ClassLoader.getSystemClassLoader(),
新类[]{t.getClass().getInterfaces(),
新的调用代理(t)
);
}捕获(例外e){
e、 printStackTrace();
返回null;
}
}
公共静态void main(字符串[]args){
listl1=InvocationProxy.makeProxy(newarraylist());
l1.添加(num1);
l1.添加(num2);
l1.增加(num3);
.
.
.
还是别的什么
}
}

我想从给定参数创建一个代理并使用它。