5

我想知道当您在创建动态代理实例时调用该newProxyInstance方法时,参数究竟是什么ClassLoader

public static Object newProxyInstance(ClassLoader loader, Class<?>[] interfaces, InvocationHandler h) throws IllegalArgumentException

非常感谢!

PS我不确定如何正确使用代码格式化标签。

4

1 回答 1

3

的文档newProxyInstance定义其用途等同于:

Proxy.getProxyClass(loader, interfaces).
    getConstructor(new Class[] { InvocationHandler.class }).
    newInstance(new Object[] { handler });

因此,如果您想了解更多关于 . 的详细信息loader,可以查看getProxyClass. 基本上,它只是用作定义生成的代理类的类加载器。

于 2011-02-17T19:51:23.153 回答