Bug 307009

Summary: Declare soft does not match call pointcuts with annotations in another class, when -sourceroots is used
Product: [Tools] AspectJ Reporter: Robert Dyer <psybers>
Component: CompilerAssignee: aspectj inbox <aspectj-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: aclement
Version: unspecified   
Target Milestone: 1.6.9M2   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Test case to reproduce bug. none

Description Robert Dyer CLA 2010-03-24 22:57:46 EDT
Build Identifier: AspectJ Compiler 1.6.8 (1.6.8 - Built: Friday Jan 8, 2010 at 21:53:37 GMT) - Eclipse Compiler 0.785_R33x, 3.3 

If you have a declare soft with a call pointcut, and the call pointcut is selecting methods with an annotation it will fail to match (fail to soften the exception) if:

a) the annotated method being called is in another class
b) *you compile using -sourceroots*!

Compiling with "ajc -1.5 -sourceroots ." causes the bug to manifest.

Compiling with "ajc -1.5 *.aj *.java" works normally.

I will attach a simple test case.

Reproducible: Always

Steps to Reproduce:
1. declare soft : Exception : call (@Ann * *(..));
2. call a method annotated with @Ann in class C, from class C2
3. compile using: ajc -1.5 -sourceroots .
Comment 1 Robert Dyer CLA 2010-03-24 22:59:59 EDT
Created attachment 162940 [details]
Test case to reproduce bug.

Make sure you compile this test case as "ajc -1.5 -sourceroots ." to reproduce.

If you compile it as "ajc -1.5 *.aj *.java" it works fine!

Also note that if the pointcut is changed to match by name, it works with both compilation methods.
Comment 2 Andrew Clement CLA 2010-03-25 22:52:22 EDT
i suspect it will be a compilation ordering issue (as you kind of confirm by saying *.aj *.java works normally).  The type containing the annotation being processed before or after the type containing the joinpoint will be the issue.  i'll try and get to it for 1.6.9 - thanks for the testcase.
Comment 3 Robert Dyer CLA 2010-03-25 23:18:53 EDT
I can confirm it is an ordering problem.

rdyer@narmada:~/bug$ ajc -1.5 Test.java Test2.java Ann.java Bug.aj 

rdyer@narmada:~/bug$ ajc -1.5 Test2.java Test.java Ann.java Bug.aj 
/home/rdyer/bug/Test.java:4 [error] Unhandled exception type Exception
new Test2().m2();
^^^^^^^^^^^^^

1 error
Comment 4 Andrew Clement CLA 2010-04-29 15:49:49 EDT
test and fix committed. thanks for the testcase!