Bug 265360 - [ataspectj] Incorrectly matching types against imports for annotation style aspects built with ajc
Summary: [ataspectj] Incorrectly matching types against imports for annotation style a...
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Windows Vista
: P3 normal (vote)
Target Milestone: 1.6.4   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-18 15:06 EST by Andrew Clement CLA
Modified: 2009-02-18 17:22 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Clement CLA 2009-02-18 15:06:47 EST
Discovered by Ramnivas, compiling this should fail:

package example;

import org.aspectj.lang.annotation.*;

import java.util.Date;

@Aspect
public class Main {
  @Pointcut("execution(Date foo())") 
  public void pc() {}
  
  @Before("pc()")
  public void log() {}
  
}

because although Date is imported, the reference is from a pointcut string.  Compiling with javac then weaving later would not have worked, so ajc shouldn't work either.
Comment 1 Andrew Clement CLA 2009-02-18 17:22:52 EST
quite complex to fix as other parts of the compiler are building a cache per source file of types they can easily see.  Overriding this to say 'no, you cant see things via import' is not trivial, but I have an implementation that appears to work.  So unqualified types in annotation style pointcuts will be resolved against types in the same package as the aspect declaration or types in java.lang

I've only tested it for basic pointcuts - I wonder if all the other language constructs that use strings use the same route through the code? I worry they dont...