简体   繁体   English

为什么jdk动态代理在调试每一步模式时调用InvocationHandler.invoke“toString”方法

[英]Why jdk dynamic proxy invoke InvocationHandler.invoke “toString” method when debug every step over mode

When I use jdk dynamic proxy ,seems当我使用 jdk 动态代理时,似乎

Object proxy = Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
                    new Class<?>[] { xx }, handler);

When I debug the program ,step over one by one, handler variant will invoke its method following with "toString" method当我调试程序时,一步一步来,处理程序变体将调用它的方法,并使用“toString”方法

@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    }
    if (method.getName().equals("toString")){
        System.out.println( " toString " +args);//**executed every step over line,why??**
        return method.invoke(target,args);
    }

But it is is no problem when not debug mode.但是在非调试模式下是没有问题的。

在此处输入图片说明

I guess IDE need to display the info in the red box, this leads to invoking of the object's toString() method.我猜 IDE 需要在红框中显示信息,这会导致调用对象的toString()方法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么InvocationHandler中的方法invoke()有一个参数Object proxy? - why does the method invoke() in InvocationHandler have an parameter Object proxy? 为什么我可以在InvocationHandler的invoke()方法中调用proxy.getClass()? - Why can I call proxy.getClass() inside InvocationHandler's invoke() method? 了解java.lang.reflect.InvocationHandler的invoke方法的“代理”参数 - Understanding “proxy” arguments of the invoke method of java.lang.reflect.InvocationHandler 使用InvocationHandler在代理类中调用NoClassDefFound并调用 - NoClassDefFound in proxy class using InvocationHandler and invoke 调用的java.lang.reflect.InvocationHandler的方法参数列表中的“代理”对象代表什么? - What does “proxy” object from invoke's method parameters list of java.lang.reflect.InvocationHandler represent? 对我的代理类中的每个方法执行InvocationHandler调用方法 - Execute InvocationHandler invoke method for each method at my proxied class Java动态调用通过对象动态附加(通过动态代理)的方法 - Java dynamically invoke method which is dynamically attached (by dynamic proxy) on an object 如何从动态代理显式调用默认方法? - How to explicitly invoke default method from a dynamic Proxy? 如何在没有反射和动态代理的情况下简单地显式调用默认方法? - How to explicitly invoke default method simply, without reflection and dynamic Proxy? 在代理上调用接口默认方法 - Invoke an interface default method on a proxy
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM