Hello,
I created an aspect to do some exception translation based on the presence
of an annotation:
public aspect TranslateThrowsAspect {
pointcut AnyAnnotatedMethod() : execution(@TranslateThrows * *.*(..));
pointcut AnyPublicMethodInAnAnnotatedClass() : execution(public *
(@TranslateThrows *).*(..));
pointcut AnyExceptionTranslatorMethod() : execution(*
ExceptionTranslator.*(..));
pointcut AnyEligibleMethod() :
( AnyAnnotatedMethod() && !AnyExceptionTranslatorMethod() ) ||
( AnyPublicMethodInAnAnnotatedClass() &&
!AnyExceptionTranslatorMethod() );
pointcut AnyEligibleMethodCapturingTarget(ExceptionTranslator obj) :
AnyEligibleMethod()
&& target(obj);
after(ExceptionTranslator obj) throwing (Exception e) :
AnyEligibleMethodCapturingTarget(obj) {
throw obj.translateException(e);
}
declare soft: Exception : AnyEligibleMethod();
}
So if you have @TranslateThrows on a class, then all public methods that
throw are sent through the exception translator and the checked exceptions
are softened. When I run my tests with ADJT everything works wonderfully.
I am using ADJT with M2E-AJDT so its all integrated.
When I run in Maven the softening happens, but the after throwing advice is
not woven. I see this in the logs:
[INFO] Softening exceptions in type
'com.argodata.core.aspect.TranslateThrowsAspectTest$ClassWithNoTranslator'
(TranslateThrowsAspectTest.java:52) as defined by aspect
'com.argodata.core.aspect.TranslateThrowsAspect'
(TranslateThrowsAspect.class:86(from TranslateThrowsAspect.aj))
[DEBUG] woven class
com.argodata.core.aspect.TranslateThrowsAspectTest$ClassWithNoTranslator
(from
/home/ashsteph/workspace/java-core-project_trunk/argo-commons/src/test/java/com/argodata/core/aspect/TranslateThrowsAspectTest.java)
[DEBUG] woven class com.argodata.core.aspect.TranslateThrowsAspectTest (from
/home/ashsteph/workspace/java-core-project_trunk/argo-commons/src/test/java/com/argodata/core/aspect/TranslateThrowsAspectTest.java)
[INFO] Softening exceptions in type
'com.argodata.core.aspect.TranslateThrowsAspectTest$ClassWithTranslator'
(TranslateThrowsAspectTest.java:37) as defined by aspect
'com.argodata.core.aspect.TranslateThrowsAspect'
(TranslateThrowsAspect.class:86(from TranslateThrowsAspect.aj))
So I can see the softening happen (note that the soften advice is declared
in the same .aj file (see above). However, I see no corresponding "Join
Pointy 'method-execution..." messages for the advice as I do for other
aspects. Then (confirming again the observations) I get this at the end of
the test-compile:
[WARNING] advice defined in com.argodata.core.aspect.TranslateThrowsAspect
has not been applied [Xlint:adviceDidNotMatch]
Note that all of the other aspects are working fine and are siblings of the
TranslateThrows in the same package. And the whole thing works and weaves
and translates great in AJDT. I'm a little lost here are where to look next
for diagnostic information. I have tried splitting the .aj files -- to put
the soften in one and the after throwing advice in another but that made no
difference. Only other thing I can think of is that eclipse is using a
newer AspectJ version (1.6.11?) instead of 1.6.10 which is what the plugin
seems to be using. Anyone know how to force the plugin to use another
version? I see 1.6.11 in the maven repo.
Thanks,
Steve
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users