Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AJDT » Advice on Constructors With Subclasses
Advice on Constructors With Subclasses [message #599076] Tue, 02 September 2008 23:30
James Elliott is currently offline James ElliottFriend
Messages: 2
Registered: July 2009
Junior Member
I am attempting to write some advice that will run only after the
construction has completely finished, i.e. after the an object has been
completely initialized.

An object can be created in any of the types in an inheritance tree, and
thus, I would like to advise all of the constructors, but only run the
advice once, after the object has been constructed.

This is probably easier to describe via an example:

public class A {
public A() {
System.out.println("init A");

public class B extends A {
public B() {
System.out.println("init B");

public class C extends B {
public C() {
System.out.println("init C");

after(A item) : execution( && target(item) {

public static void main(String[] args) {
C c = new C();
B b = new B();

The above code has the following output:
init A
init B
init C

init A
init B

What I am attempting to create is advice that will produce the following:
init A
init B
init C

init A
init B

i.e. Only run the advice after the object is completely created

I have tried a few approaches, including !within( and
!cflow(execution(, but due to the way the compiler inlines the
super() calls, these approaches produce the same results as above.

Does anybody have any experience with this problem, and/or suggestions on
how to solve it?
Previous Topic:Advice on Constructors With Subclasses
Next Topic:aspectj source/trunk
Goto Forum:

Current Time: Tue May 22 06:35:35 GMT 2018

Powered by FUDForum. Page generated in 0.01909 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top