java - Advice defined has not been applied with AspectJ -
i have aspectj - project aspect making system.out.println's learning little bit aspects etc.
the problem is, advices define cuts doesn't work. warning shown is: advice defined in shapeaspect has not been applied [xlint:advicedidnotmatch]
i'm working mac os x 10.10 yosemite, eclipse luna service release 2 (4.4.2) , aspectj runtime: org.aspectj.runtime_1.8.5.20150128171000.jar, ltw classes etc.: org.aspectj.weaver_1.8.5.20150128171000.jar , additionally org.aspectj.ajde_1.8.5.20150128171000.jar.
my simple defined aspect:
public aspect shapeaspect { // pointcuts pointcut mypointcut2() : execution(oldshape.point.new(..)); // advices before() : mypointcut2(){ system.out.println("before init."); } } edit: including point class
public class point implements shape{ private int x,y; public point(int x, int y){ this.x = x; this.y = y; } ... @override public void draw(gc gc) { color c = new color(gc.getdevice(), 0, 0, 255); gc.setforeground(c); gc.drawpoint(this.x, this.y); c.dispose(); } } public class swtmain{ public static void main(string[] args){ shape s1 = new point(4,4); s1.draw(gc); } } but @ line of before().. warning: advice defined in shapeaspect has not been applied [xlint:advicedidnotmatch]
what problem here? on pc windows works correctly?
the warning can surpress @suppressajwarnings({"advicedidnotmatch"}).
make sure new method declared public.
try specifying return type in execution like:
pointcut mypointcut2() : execution(* oldshape.point.new(..)); if not working, try wildcard method name well. like:
pointcut mypointcut2() : execution(* oldshape.point.*(..)); also, don't know call from, can try using call instead of execute ( read more them here).
along lines of:
pointcut mypointcut2() : call(* oldshape.point.new(..)); or
pointcut mypointcut2() : call(* oldshape.point.*(..)); should run before advice.
Comments
Post a Comment