Bug 74128 - Visibility of introductions in anonymous classes
Summary: Visibility of introductions in anonymous classes
Status: RESOLVED INVALID
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-09-16 17:38 EDT by Franz Prilmeier CLA
Modified: 2005-03-23 08:40 EST (History)
0 users

See Also:


Attachments
Testcase (1.15 KB, application/octet-stream)
2004-09-16 17:40 EDT, Franz Prilmeier CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Franz Prilmeier CLA 2004-09-16 17:38:26 EDT
Declare a new private member to a class. Then try to access that member in an
anonymous class within an introduced method -> compile error:

compile:
     [iajc] F:\test\TestAspect.aj:40 error The field addPA is not visible
     [iajc] MainUI.this.addPA.setEnabled ( false );
     [iajc] F:\test\TestAspect.aj:41 error The field removePA is not visible
     [iajc] MainUI.this.removePA.setEnabled ( true );
     [iajc] MessageHolder:  (2 error)
     [iajc] [error   0]: error at MainUI.this.addPA.setEnabled ( false );
     [iajc] F:\test\TestAspect.aj:40:0 The field addPA is not visible
     [iajc] [error   1]: error at MainUI.this.removePA.setEnabled ( true );
     [iajc] F:\test\TestAspect.aj:41:0 The field removePA is not visible

See attachment for associated test case.
Comment 1 Franz Prilmeier CLA 2004-09-16 17:40:00 EDT
Created attachment 14585 [details]
Testcase

The included ant build script needs aspectjrt.jar and aspectjtools.jar in the
same directory in order to run.
Comment 2 Franz Prilmeier CLA 2004-09-16 17:49:13 EDT
If I declare the members as public, the code compiles.

BTW. the test case is just for compile time testing, not for runtime test.
Comment 3 Adrian Colyer CLA 2005-03-23 08:40:33 EST
Inter-type declared methods can only see members visible to the aspect in which
they are declared (so whilst 'this' inside an ITDM is a reference to the target
object instance, this does not imply that the member has the same access to
private member fields as a regular method in the type). If you want an ITDM to
be able to access private members of the target type, you have to mark the
declaring aspect as priviliged.