一旦我创建了一个InvocationHandler实现,我可以将它与Proxy.newProxyInstance函数一起使用,以使对象的行为方式不同。在这种情况下,我必须创建一个接口及其实现类来使用Proxy.newProxyInstance函数:
MyInterface objDest = Proxy.newProxyInstance(MyInterfaceImpl.class.getClassLoader(),
MyInterfaceImpl.class.getInterfaces(),
new MyInvocationHandler(new MyInterfaceImpl()));
是否可以使用没有接口的简单类直接执行相同的任务?