I am using the Javassist Loader and Reflection classes from javassist.reflect, to stub-out and mock classes transparently, especially when performing unit tests.
I have found that when used with the reflective Loader, Reflection can stub-out and intercept everything (i.e. methods, fields, statics) with the exception of Constructors. In order to be able to transparently mock certain classes, I need to be able to intercept their constructors, as these may throw Exceptions, e.g. due to resource dependencies that we are trying to mock-out, such as database connections etc. I have started adding constructor interception as an optional feature of javassist.reflect.Reflection, and the purpose of this posting is to seek community feedback on whether others might find this sensible/useful. Depending on what is possible through the rest of the API, particularly CtNewConstructor, I am thinking that the best design approach might be to copy the way Method interception works, by "moving" the real Methods and introducing a delegating stub Constructor. I'm guess that this will delegate to a Method in a subclass of Metaobject. As the real classes' Constructor has been intercepted, it would then be up to the Metaobject to instantiate a suitable replacement underlying object to delegate to. Any other approaches? Any thoughts/comments, however brief, most welcome ... I need to code this now ... may need some help from interested parties ... Brett Randall View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3841143#3841143 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3841143 ------------------------------------------------------- This SF.Net email sponsored by Black Hat Briefings & Training. Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com _______________________________________________ JBoss-Development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development