Community
Participate
Working Groups
I'm using the ajc embedded in the latest dev build of AJDT (build 20050713163417) This small example illustrates the problem: public abstract aspect AbstractRequestMonitor { public pointcut requestExecution(RequestContext requestContext) : execution(* RequestContext.execute(..)) && this(requestContext); public abstract class RequestContext { public abstract Object execute(); } after(RequestContext requestContext) throwing (Throwable t) : requestExecution(requestContext) { } } import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @Retention(RetentionPolicy.RUNTIME) public @interface AroundAdvice { } public aspect ErrorHandling { declare soft: Exception: !@annotation(AroundAdvice) && !withincode(* * (..)); Object around() : adviceexecution() && !@annotation(AroundAdvice) { try { return proceed(); } catch (Exception e) { return null; } } } Here's the stack trace I get: org.aspectj.weaver.BCException: bad at org.aspectj.weaver.bcel.BcelRenderer.visit(BcelRenderer.java:228) at org.aspectj.weaver.ast.Literal.accept(Literal.java:29) at org.aspectj.weaver.bcel.BcelRenderer.recur(BcelRenderer.java:151) at org.aspectj.weaver.bcel.BcelRenderer.renderTest (BcelRenderer.java:117) at org.aspectj.weaver.bcel.BcelAdvice.getTestInstructions (BcelAdvice.java:445) at org.aspectj.weaver.bcel.BcelShadow.weaveAroundClosure (BcelShadow.java:2585) at org.aspectj.weaver.bcel.BcelAdvice.implementOn(BcelAdvice.java:182) at org.aspectj.weaver.Shadow.implementMungers(Shadow.java:480) at org.aspectj.weaver.Shadow.implement(Shadow.java:358) at org.aspectj.weaver.bcel.BcelClassWeaver.implement (BcelClassWeaver.java:1703) at org.aspectj.weaver.bcel.BcelClassWeaver.weave (BcelClassWeaver.java:389) at org.aspectj.weaver.bcel.BcelClassWeaver.weave (BcelClassWeaver.java:94) at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1362) at org.aspectj.weaver.bcel.BcelWeaver.weaveWithoutDump (BcelWeaver.java:1327) at org.aspectj.weaver.bcel.BcelWeaver.weaveAndNotify (BcelWeaver.java:1106) at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:981) at org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.weave (AjCompilerAdapter.java:286) at org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.afterCompiling (AjCompilerAdapter.java:165) at org.aspectj.ajdt.internal.compiler.CompilerAdapter.ajc$afterReturning$org_aspec tj_ajdt_internal_compiler_CompilerAdapter$2$f9cc9ca0(CompilerAdapter.aj:70) at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile (Compiler.java:368) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation (AjBuildManager.java:727) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild (AjBuildManager.java:206) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild (AjBuildManager.java:140) at org.aspectj.ajde.internal.CompilerAdapter.compile (CompilerAdapter.java:121) at org.aspectj.ajde.internal.AspectJBuildManager$CompilerThread.run (AspectJBuildManager.java:191)
One for Andy... ;)
for M4
Heres my reduced program that also fails: import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @Retention(RetentionPolicy.RUNTIME) public @interface AroundAdvice { } aspect ErrorHandling { before(): !@annotation(AroundAdvice) { } } the '!' is causing the problem.
Fix checked in. We were always returning 'Literal.TRUE' from findResidueInternal for the annotation pointcut type which became a 'Literal.FALSE' due to the NOT. We always blow up if attempting to visit (generate) a test that is Literal.FALSE (since we shouldn't have gotten to this point claiming it was ever a match). The fix is to make findResidueInternal() return either TRUE or FALSE depending on whether the shadow actually matched the pointcut. In the case where a join point does *not* have the annotation, it will now return FALSE, which will become TRUE due to the ! and this is a valid test. waiting on build before closing bug.
Fix available now.