Bug 147841 - advice is not woven from jar on aspectpath when 'this' or 'target' is included in the pointcut
Summary: advice is not woven from jar on aspectpath when 'this' or 'target' is include...
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: 2006-06-20 05:37 EDT by Helen Beeken CLA
Modified: 2013-06-24 11:03 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Helen Beeken CLA 2006-06-20 05:37:37 EDT
Compiling the following aspect

--------------------------------------------------------------------------
package pkg;

public aspect A {

	before() : execution(* pack.C.method1()) && this(pack.C) {
		System.out.println("before exec method1 and this is C");
	}
	
	before() : call(* pack.C.method2()) && target(pack.C) {
		System.out.println("before call to method2 and target is C");
	}
}
-------------------------------------------------------------------------

and placing the resultant class file on the aspectpath for a project containing the following class 

------------------------------------------------------------------
package pack;

public class C {

	public C() {
	}
	
	public void method1() {
		new C().method2();
	}
	
	public void method2() {
	}
	
	public static void main(String[] args) {
		new C().method1();
	}
	
}
------------------------------------------------------------------

results in no weaving taking place unless the compiled class C is put on the build path when the aspect is built. Removing the 'this' and 'target' from the pointcuts everything works as expected (weaving takes place regardless of whether C is put on the build path when the aspect is built).

Note the same behaviour occurred on 1.2.1.
Comment 1 Andrew Clement CLA 2006-06-22 11:57:45 EDT
this bug is what I suspected.  During the initial build of the aspect, the type pattern in this or target (which must be an exact type pattern) is resolved to NoTypePattern (because the type cannot be found). It is then serialized as NoTypePattern and later deserialized for the secondary compile as a NoTypePattern - this matches nothing ...

Should probably serialize the pre-resolved form.

I dont think this affect incremental compilation as it is only an issue if the type pattern cannot be resolved in a world.  In the world behind incremental compilation of a project, the type *will* exist and everything will work fine.
Comment 2 Andrew Clement CLA 2006-06-23 03:35:03 EDT
of course...this will be currently affecting *all* pointcuts that get a fully specified type pattern (some require it eg. this/target whilst in others it can either by fully specified or a pattern).

it is a serious change to switch how we are working here because we assume all deserialized pointcuts are fully (correctly) resolved.  So I dont think this should be done for 1.5.2
Comment 3 Andrew Clement CLA 2006-06-23 03:36:07 EDT
i turned helens code into a testcase - the expected output isnt correct but the basics are there, its commented out in Ajc152tests...
Comment 4 Andrew Clement CLA 2007-10-24 10:57:31 EDT
restriction that we ought to look at resolving for 1.6.0 - surely we can serialize in some other form?
Comment 5 Andrew Clement CLA 2013-06-24 11:03:26 EDT
unsetting the target field which is currently set for something already released