[cdi-dev] Improve debugging support for class-based proxies - supported by CDI or CDI implementations?
jens.schumann at openknowledge.de
Tue May 7 10:15:28 EDT 2013
With the advent of class-based proxies my team and I have been fooled by debuggers quite often. To be honest I don't want to know how many hours we wasted so far while looking at the attributes of an proxy wondering why the application behaved differently (based on what the attributes of that proxy said ;). Even experienced developers usually need some time to detect that the attribute they are looking at are the default values of the class and not the values of the target instance.
Therefore I am wondering if we could help IDE providers to detect such situations and provide useful hints to developers. At a minimum I would ask for a simple "this is not the real instance"-hint, best case the debugger shows the values of the target instance. Some time ago I asked the IDEA guys (1) for better class-based proxy support in their debugger, nevertheless it would remain a proprietary solution once implemented.
I am not an expert in that field, but here are my thoughts.
- Across all bytecode manipulation/ bytecode generation frameworks there is no common way to detect whether a given object instance is a proxy or not.
- There is no direct JVM/java class library support either, apart from Class.isSynthetic – see 4.7.6 The Synthetic Attribute in (2)
- A debugger could simply rely on Class.isSynthetic to show a simple hint (if all CDI implementations would set this attribute – see 3)
- We could ensure that proxies implement a common CDI SPI interface that allows access to the target instance. (If it wouldn't take that long the interface should be part of java.lang.reflect or similar).
What do you think?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cdi-dev