Bug 188291 - pointcut definition with "if" designator or array type patterns inappropriate in runtime visible annotations (@Pointcut, @Before, @After, @Around, @AfterReturning, @AfterThrowing)
Summary: pointcut definition with "if" designator or array type patterns inappropriate...
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-22 08:45 EDT by Christoph Bockisch CLA
Modified: 2007-06-07 04:53 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Bockisch CLA 2007-05-22 08:45:12 EDT
Build ID: 1.5.4.200701151324

Steps To Reproduce:
I am using AJDT 1.5M7 (including AspectJ 1.5.4.200701151324) and Eclipse 3.3RC1. To reproduce the bug, use the following aspect and class:

==================

public aspect Aspect1 {

	pointcut pc() : call(* *(..)) && if(0==0) && args(Type[]);

}


public class Main {

	public static void main(String[] args) throws Exception {
		Class clazz = Class.forName("Aspect1");
		
		System.out.println("Methods:");
		Method[] methods = clazz.getDeclaredMethods();
		for(int i = 0; i < methods.length; i++) {
			if(methods[i].getAnnotations().length == 0)
				continue;
			System.out.println(methods[i]);
			printAnnotations(methods[i].getAnnotations());
		}
	}

	private static void printAnnotations(Annotation[] annotations) {
		for(int i = 0; i < annotations.length; i++) {
			System.out.println(annotations[i]);
		}
	}
}

=============

The output is something like:

Methods:
void Aspect1.ajc$pointcut$$pc$6f()
@org.aspectj.lang.annotation.Pointcut(argNames=, value=(call(* *(..)) && (if(void java.lang.Object.if_()) && args(Type))))

The method "Object.if_()" does not exist and the pointcut designator "if" should rather contain the signature of the method that has been generated from the "if"-expression ("0==0" in the example). In my test run, the method "ajc$if_112()Z" has been generated, thus I would expect to see

if(boolean Aspect1.ajc$if_113())

in the annotation.

And the last pointcut designator "args" shows that the argument type should be "Type", however, in the pointcut definition it was said that the argument type has to be the array type Type[]. Consequently, it should be:

args(Type[])

More information:
Comment 1 Andrew Clement CLA 2007-06-07 04:53:52 EDT
you might have more luck grabbing the PointcutDeclaration classfile attribute which retains more info than the annotation.  However, I know you cannot do this without picking the classfile apart since it isnt as readily available as the annotation - i'm just thinking of what you can do if this does not get addressed in the short term.  Having the annotation contain unhelpful information isn't good - but it isn't breaking anything at the moment.  Right now the annotation is built before the name of the if() method is worked out so that would all have to be addressed.