Bug 237381

Summary: @DeclareWarning and @DeclareError not working in code style aspect---can't mix annotation style with code style
Product: [Tools] AspectJ Reporter: Andrew Eisenberg <andrew.eisenberg>
Component: CompilerAssignee: aspectj inbox <aspectj-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: aclement
Version: 1.6.1   
Target Milestone: 1.6.1   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Andrew Eisenberg CLA 2008-06-16 17:52:38 EDT
The following should raise an error on the foo() method, but does not:

import org.aspectj.lang.annotation.DeclareWarning;
import org.aspectj.lang.annotation.Aspect;
@Aspect
public aspect A {
	@DeclareWarning("execution(void *.foo(..))")
	static final String h = "barf";
	void foo() { }
}


The following does work as expected:
import org.aspectj.lang.annotation.DeclareWarning;
import org.aspectj.lang.annotation.Aspect;
@Aspect
public class A {
	@DeclareWarning("execution(void *.foo(..))")
	static final String h = "barf";
	void foo() { }
}

so it seems like it is not possibleto mix @AspectJ style declares in code style aspects.
Comment 1 Andrew Clement CLA 2008-06-17 16:29:56 EDT
this was actually policed by the compiler to behave in this way.  I've changed it to allow it - I am concerned a little about performance but we do seem to check the constant pool for references to any kind of annotation before doing a detailed analysis of whether every method is a pointcut or an advice or deow, etc.

it is not common to mix things up in this way, in fact I'd have thought the other way round was more likely (@Aspect on the class then code style syntax inside, as that may keep other parts of JDT happier whilst you are editing a mostly regular class).