Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] target(object and al extending objects)

Hello,

I think my question is rather trivial, but after long hours of searching, I still don't find how to solve my problem.

With a pointcut like

pointcut findConstructors(): call(SomeSuperClass+.new (..));

I can find all the calls to constructors from SomeSuperClass and all the classes that extend SomeSuperClass.

With a pointcut like

pointcut findConstructors(MyClass obj): call (MyClass.new (..));

I can find all the calls to constructors from MyClass and I can do something with the object obj in the advice that uses this pointcut.

My problem is how to combine those two things. I want a pointcut that finds all calls to constructors in a superclass and al the classes that extend that superclass PLUS in the advice (after advice) I would like to have a reference to the object that was just constructed. I expect that I will have to cast it to the correct subclass? But how can i reach that object?

I had something like this in mind, but that doesn't compile:

pointcut findConstructors(SomeSuperClass+ superclass):
	call(SomeSuperClass+.new(..)) && target(superclass);

thanks in advance,
Jan



Back to the top