Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] advice on introduced default implementation

Hello,

i have stumbled upon an aspectj behaviour that I have no explanation for.
Could someone please be so kind and have a look at this short example
and give me a hint?

public interface Foo {

	public void foo();
	
}

public interface Bar extends Foo {

	public void bar();
}

public class FooImpl implements Foo {

	public void foo() {
		System.out.println("foo");
	}
}

public class BarImpl implements Bar {

	public void bar() {
		System.out.println("bar");
	}
	
	public void foo() {
		System.out.println("foo");
	}
}

public aspect BarAspect {

	public void Bar.bar() {
		System.out.println("bar");
	}

	declare parents: FooImpl implements Bar;
	
	pointcut test(): execution(public void Bar.bar());
	
	before(): test() {
		System.out.println(thisJoinPoint);
	}
}


The BarAspect test() advice advises only BarImpl.bar() and not
the default implementation provided in BarAspect. So the execution
of new FooImpl().bar() gets not advised.

Is this intended? And why behaves aspectj this way.

Thank you very much,
Vincenz



Back to the top