Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] advice on introduced default implementation (solved)

Thank you very much for you reply.

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

introdcues a default implementation on this interface.
With declare parents: FooImpl implements Bar; FooImpl
is a Bar and must provide an implementation of bar(). The BarAspect
does this with the above introduction. If you remove the Bar. in the
code above the BarAspect has a method bar() but the code does
not compile due to "FooImpl must implement inherited abstract method Bar.bar()".

The weaving works fine I saw today. The AJDT markers where confusing me. They show only advises (I) Bar and BarImpl.bar. On the introduction you only find the declared on annotation. On my "real code" there were introductions for more than one method which lead me to the wrong conclusion that the advice gets not applied to the default implementation because there
was only one entry of of this Interface in the advised on list.

Sorry for the noise,
Vincenz

Am 12.11.2006 um 05:42 schrieb Ron DiFrango:

I am not sure I have the answer, but I think your does the declaration of the bar() method really need to be something like:

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

Notice the missing Bar.

Just a thought!

-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx on behalf of Vincenz Braun
Sent: Sat 11/11/2006 1:02 PM
To: aspectj-users@xxxxxxxxxxx
Subject: [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

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users

<winmail.dat>
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users

--

vincenz braun
evelox Consulting GmbH & Co. KG

email:  vb@xxxxxxxxx
phone: +49 700 VINCEBRAUN
mobile: +49 179 2190118




Back to the top