本帖最后由 邵阳 于 2012-9-15 12:49 编辑
代码如下
package cn.itcast.day3;
import java.awt.event.InvocationEvent;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Collection;
public class MyProxy
{
public static void main(String[]args) throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException
{
Class clazzProxy=Proxy.getProxyClass(Collection.class.getClassLoader(), Collection.class);
System.out.println(clazzProxy.getName());
Constructor constructor=clazzProxy.getClass().getConstructor(InvocationHandler.class);
}
}
怎么输出结果老是
$Proxy0
Exception in thread "main" java.lang.NoSuchMethodException: java.lang.Class.<init>(java.lang.reflect.InvocationHandler)
at java.lang.Class.getConstructor0(Class.java:2706)
at java.lang.Class.getConstructor(Class.java:1657)
at cn.itcast.day3.MyProxy.main(MyProxy.java:17)
|
|