Bug 115237 - no aspectOf() on parameterized perobject aspects
Summary: no aspectOf() on parameterized perobject aspects
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.0M4   Edit
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: 1.5.0RC1   Edit
Assignee: Andrew Clement CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-06 08:09 EST by Wes Isberg CLA
Modified: 2005-11-18 03:12 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 Wes Isberg CLA 2005-11-06 08:09:40 EST
Assuming (without adk15 objection) that parameterized aspects can be
instantiated per-object, I am not seeing an aspectOf(..) method, only
aspectof().  Not true of unparameterized types.
--------------------------------------------------------
public class PerTarget {
	public static void main(String[] args) {
		C c = new C();
		c.go();
		A a = A.aspectOf(c);
		// ok, illegal - aspectOf only on concrete aspects?
		// AA aa = AA.aspectOf(c);

		// hmm - n/a for parameterized types?
		//CAPT capt  = CAPT.aspectOf(c); // unexpected compile error here
		//System.out.println("A " + a + " capt " + capt);
	}
	static class C {
		void go() {}		
	}
	abstract static aspect AA pertarget(pc()) {
		abstract pointcut pc();
		before() : pc() {
			System.out.println("go()");
		}
	}
	static aspect A extends AA {
		pointcut pc() : call(void C.go());
	}
	abstract static aspect APT<T> pertarget(pc()) {
		abstract pointcut pc();
		before() : pc() {
			System.out.println("go()");
		}
	}
	static aspect CAPT extends APT<C> {
		pointcut pc() : call(void C.go());
	}
}
Comment 1 Andrew Clement CLA 2005-11-15 12:11:15 EST
I think it is generating an aspectOf() - the problem is the type checking during
compilation isn't able to *see* the aspectOf(), it is probably asking the wrong
object (maybe the generic type, when the aspectOf is on the parameterized form).
Comment 2 Andrew Clement CLA 2005-11-15 12:15:25 EST
oops - spoke too soon, aspectOf() that is generated isnt quite right...
Comment 3 Andrew Clement CLA 2005-11-17 07:45:21 EST
What a can of worms!!  The problem was that we werent correctly looking up the
perclause of the super aspect if it was a parameterized type - I added the logic
for this.  Without this we default to persingleton().

This then revealed some problems with @AJ processing of per clauses - I am
concerned that we test whether a class is 'AnnotationStyleAspect' by checking
for the existence of the 'Aspect' annotation - because we have a visitor that
runs over any code style aspect and adds those annotations.  I haven't fixed
this problem but merely fixed up the handling of perclauses to be correct (at
least correct enough for all our existing testcases).

fix checked in.
Comment 4 Andrew Clement CLA 2005-11-18 03:12:35 EST
fix available.