[cdi-dev] Improve debugging support for class-based proxies - supported by CDI or CDI implementations?

Jens Schumann jens.schumann at openknowledge.de
Tue May 7 10:15:28 EDT 2013


Hi all!

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?

Jens
(1) http://youtrack.jetbrains.com/issue/IDEA-88756
(2) http://docs.oracle.com/javase/specs/jvms/se5.0/html/ClassFile.doc.html
(3) https://issues.jboss.org/browse/WELD-1417
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/cdi-dev/attachments/20130507/78c6921c/attachment-0001.html 


More information about the cdi-dev mailing list