Community
Participate
Working Groups
Given the following point cut and advice: public aspect ExceptionAspect { pointcut exceptionThrower() : execution(public * ExceptionBugTest.*(..) throws Exception+); declare warning : exceptionThrower() : "throws Exception+"; } And the to be aspected code: public class ExceptionBugTest { class MyException extends Exception { } public void method1() throws Exception { } public void method2() throws MyException { } } listing file default.lst: C:\temp\AJC Bug\ExceptionAspect.aj C:\temp\AJC Bug\ExceptionBugTest.java AJC does not advise ExceptionBugTest.method2(). The output from the compilation is the following: C:\temp\AJC Bug>ajc -argfile default.lst -classpath %ASPECTJ_HOME%\lib\aspectjrt.jar C:\eclipse\workspace\AJC Bug\ExceptionBugTest.java:11 throws Exception+ From the aspect-j mailing list, contributed by Jim Hugunin: <detail>The bug was caused because the code for ThrowsPattern mistakenly used the internal protected method TypePattern.matchesExactly instead of the external public method TypePattern.matchesStatically. Because the classes were in the same package, Java's accessibility rules allowed this. It would be nice if there was an easy way to specifiy that a method could only be accessed from subtypes.</detail>
Created attachment 5985 [details] A to be advised class
Created attachment 5986 [details] The offending aspect and pointcut
Created attachment 5987 [details] listing file for ajc
The test provided has been added to tests/bugs/throwsSignature. This bug is now fixed in the tree for the 1.1.1 release. Thanks for the clear and easy to reproduce bug report.