Skip to main content

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

aack!

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

super(..) should never be available in advice.
That I think is a compiler bug.

wrt calling super, does it work to declare the constructor?

   Target.new() {
     super("hello");
     ...
   }

(If the default constructor is already declared, then you
can't do that.)

Another approach is to replace the calls:

  Target around() : call(Target.new()) {
     return new Target("hello");
  }

You might combine this with the inter-type declaration of
the constructor.

Since super(..) is a special form in Java, that's pretty
much all you can do in AspectJ.

Wes

On Thu, 1 Sep 2005 00:33:37 +0100 (BST)
 nathar shah <shah123khan@xxxxxxxxx> wrote:
> 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
> _______________________________________________
> aspectj-dev mailing list
> aspectj-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-dev



Back to the top