Bug 42539

Summary: throw derivative pointcuts not advised.
Product: [Tools] AspectJ Reporter: Keith Sader <keith.d.sader>
Component: CompilerAssignee: Jim Hugunin <jim-aj>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P2    
Version: 1.1.0   
Target Milestone: 1.1.1   
Hardware: PC   
OS: Windows 2000   
Whiteboard:
Attachments:
Description Flags
A to be advised class
none
The offending aspect and pointcut
none
listing file for ajc none

Description Keith Sader CLA 2003-09-04 11:15:58 EDT
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:
&lt;detail&gt;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.&lt;/detail&gt;
Comment 1 Keith Sader CLA 2003-09-04 11:16:53 EDT
Created attachment 5985 [details]
A to be advised class
Comment 2 Keith Sader CLA 2003-09-04 11:17:19 EDT
Created attachment 5986 [details]
The offending aspect and pointcut
Comment 3 Keith Sader CLA 2003-09-04 11:17:33 EDT
Created attachment 5987 [details]
listing file for ajc
Comment 4 Jim Hugunin CLA 2003-09-04 11:44:35 EDT
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.