Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-dev] Constructor Join Point and Super() constructor

Hi,

I am looking at ways of developing an aspect which
will call super() in the constructor so that its super
constructor can be called. For example if I have class
such as 

public class Tester{
   public Tester(){
   }
}

Currently implicit super() constructor is called
automatically. But I want an aspect which will call
explicit super() constructor with some arguments.The
class structure of Tester will be modified using
declare parents. I have developed an aspect such as
follows but facing problem when it is weaved saying
"super constructor call must be the first statement in
the constructor"

aspect Test{
 declare parents: Tester extends Superclass;

 ClassA a = new ClassA();
 ClassB b = new ClassB();
 
 pointcut cons(): preinitialization(Tester.new());

 void around(): cons(){
   super(a, b);
   proceed();
 }
}

Note: I need the aspect to modify the Tester class
structurally by extending Superclass class. Thus, I
need to call Super() constructor with some arguments
before the constructor of Tester is executed. 

This is a simple simulation of the problem I am facing
in my application development. Could anyone there help me?




		
___________________________________________________________ 
How much free photo storage do you get? Store your holiday 
snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com


Back to the top