Bug 65319

Summary: ajc crashes when compiling the following program (binding this() and target())
Product: [Tools] AspectJ Reporter: c03sk
Component: CompilerAssignee: Adrian Colyer <adrian.colyer>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3    
Version: 1.2   
Target Milestone: 1.2.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description c03sk CLA 2004-06-02 10:29:50 EDT
class Test
{  
	public static void main(String args[])
	{		
		new Test().method();
	}
	public void method()
	{
		new Test2().method2();
	}
}
class Test2 {
	public void method2() {}
}
aspect Plain {
	before(Test x):  call(void *.* (..)) && (this(x) || target(x))
	{
	}
}
Comment 1 Andrew Clement CLA 2004-08-09 12:35:19 EDT
For this bug I propose the same solution we used for args() (bug 61568) which
will make this a proper compile time error.  Fundamentally we are saying that
you aren't allowed to bind more than once to a formal - this doesn't seem *too*
unreasonable.

Current proposal for the message is:

C:\temp\ajcSandbox\ajcTest16749.tmp\PR65319.java:9:0 
  Cannot use target() to match at this location and bind a formal to type
'Test2' - the formal is already bound to type 'Test'.  The secondary source
location points to the problematic target().
	see also: C:\temp\ajcSandbox\ajcTest16749.tmp\PR65319.java:16

If there is a compelling use case we could look at perhaps supporting this
properly, but without one we'll stick to outputting an error.
Comment 2 Andrew Clement CLA 2004-08-10 12:25:30 EDT
Proposed fix checked in.  Message isn't great but its better than a crash at
weave time.
Comment 3 Andrew Clement CLA 2004-08-11 03:25:47 EDT
Fix available in:

BUILD COMPLETE -  build.334
Date of build: 08/10/2004 18:17:11
Time to build: 92 minutes 34 seconds
Last changed: 08/10/2004 17:33:42
Latest good AspectJ jar available at:
download.eclipse.org/technology/ajdt/dev/aspectj-DEVELOPMENT.jar
Comment 4 Adrian Colyer CLA 2004-10-21 04:31:59 EDT
Fix released as part of AspectJ 1.2.1