I have posted a proposed enhancement to the javassist.reflect package, to support constructor interception.
The enhancement provides the following additional features:
An event is generated prior to the calling of a reflected class's super constructor.
An event is generated prior to the calling of a reflected class's constructor body. This event has access to the object under-construction, and can optionally bypass the constructor body if required (the default behaviour is to execute the constructor body.
An event is generated at the completion of the reflected class's constructor body. The entire body is wrapped in a try/catch block that will catch unchecked Throwables (RuntimeException and Error), as well as any checked Exceptions declared in the constructor. The caught Throwables are available to the event along with the object under-construction, and by default they are re-thrown, or they can optionally remain caught.
The three events are available as three new callback methods in ClassMetaobject:
public void trapBeforeSuperConstructor() throws Throwable {} public boolean trapBeforeClassConstructor(Object underConstruction) throws Throwable {} // return false to bypass constructor body public boolean trapAfterClassConstructor(Object underConstruction, Throwable threw) throws Throwable {} // return false to prevent re-throw