Bug 68991 - intertype initialisers should match field set pointcuts
Summary: intertype initialisers should match field set pointcuts
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.2   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 1.2.1   Edit
Assignee: Andrew Clement CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-30 07:51 EDT by Oege de Moor CLA
Modified: 2004-10-21 04:31 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 Oege de Moor CLA 2004-06-30 07:51:21 EDT
/* initialisers of intertype fields should match field set pointcuts.

   In the example below, the output should be

set field set(int C.n)
set field set(int C.m)
get field get(int C.n)
set field set(int C.n)

   but the first field set (of C.n) is not picked up.
*/



aspect Aspect {

    private int C.n = 13;

    before() : get(* C.*) {
	System.out.println("get field "+thisJoinPointStaticPart);
    }

    before() : set(* C.*)  {
	System.out.println("set field "+thisJoinPointStaticPart);
    }

    public void C.foo() {
	n++;
    }

}

class C {
    int m = 20;
}

public class ITFieldsAdvice {

    public static void main(String[] args) {
	C c = new C();
	c.foo();
    }

}
Comment 1 Adrian Colyer CLA 2004-08-09 15:28:19 EDT
marked as target 1.2.1
Comment 2 Andrew Clement CLA 2004-08-11 08:54:24 EDT
Fix checked in, waiting for build.

Some AspectJ facts.

- When the ITD is a private ITD, the field generated has a 'special' "ajc$XXX" name.

- *No* ajc$XXX field references are considered join points.

- Join points for references to these fields are surfaced as follows.  Each
field has a set and a get dispatcher method generated.  These methods are tagged
with the 'effective signature' attribute of a FIELD_GET or FIELD_SET shadow. 
This means when a call to the dispatcher method is found in the code, it is
matched upon as if it was a field get or set join point.

- When ITD field initializers are generated, they normally directly set the
named field.  Field initializer methods are *not* tagged with the effective
signature attribute.

The fix is to change the body of the generated field initializer so that it
delegates to the field set dispatcher method - the call to this method will
ensure the right field set join point surfaces for the match.
Comment 3 Andrew Clement CLA 2004-08-12 03:11:14 EDT
Fix available now:

BUILD COMPLETE -  build.337
Date of build: 08/11/2004 17:19:19
Time to build: 91 minutes 45 seconds
Last changed: 08/11/2004 14:18:49
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:41 EDT
Fix released as part of AspectJ 1.2.1