1 Reply Latest reply on Sep 23, 2005 1:43 PM by bill.burke

    Problems with constructor invocations

    freezy

      Hi,

      I found two use-cases for which the constructor invocation does not happen...

      UseCase 1: creating an instance within the class itself:

       Class EShopApp
       {
       [...]
       public static EShopApp create()
       {
       return new EShopApp(); // the constructor interceptor is NOT called!
       }
       [...]
       }
      


      UseCase 2: creating an instance within a JUnit TestCase:

       public class TestEShop
       extends junit.framework.TestCase
       {
       [...]
       protected void setUp() throws Exception {
       {
       EShopApp eSA = new EShopApp(); // the constructor interceptor is NOT called!
       this.setEShop(eSA);
       }
       [...]
       }
      


      I checked if the JUnit file got (AOP-)compiled, and it was. Although it worked with Eclipse's JUnit, it did not with Ant's JUnit-task (in Eclipse other important things do not work, so switching to Eclipse doesn't really help).

      UC1 & UC2 work if you use a seperate factory class to return a new instance. But I wouldn't really like to write a seperate factory for each constructor which I want to intercept...

      Am I doing something wrong? Is it not supported? Or is this another "feature" of some Java compiler or classloader?
      I tried both: aop-compiletime and aop-loadtime. Neither worked.


      Thanks in advance,

      freezy