Bug 52928 - Private members introduced via an interface are visible to the class
Summary: Private members introduced via an interface are visible to the class
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.1.1   Edit
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: 1.2   Edit
Assignee: Jim Hugunin CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-02-24 08:25 EST by Antti Karanta CLA
Modified: 2004-03-18 17:40 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 Antti Karanta CLA 2004-02-24 08:25:36 EST
If private members are introduced via an interface to classes, the introduced 
members are visible inside the classes themselves, although the visibility is 
supposed to be relative to the aspect. Here's a sample:


public class Sample {

   public static void main(String[] args) {
      Sample s = new Sample();
      s.aMethod();
   }

   public void aMethod() {
      // x is introduced by the following aspect as private
      // so it should not be accessible here
      System.out.println("I have " + x);
   }

}


aspect SampleAspect {
   private interface Tag {};
   
   private int Tag.x = 0;
   
   declare parents: Sample implements Tag;
}
Comment 1 Jim Hugunin CLA 2004-03-18 14:45:16 EST
I've confirmed this bug but don't have a fix yet.  I'm setting the target 
milestone to 1.2 to see if we can get it fixed before that release.  I'm 
assigning to Adrian as this is a bug in the compiler front-end.
Comment 2 Adrian Colyer CLA 2004-03-18 17:22:07 EST
The problem was a missed case in Scope.findField() [in the shadows). Whenever we 
find a field, we in addition check to see that it is actually visible via a call 
to field.getVisibleBinding(). I'm guessing 30 M6 added a new route for field 
finding that wasn't in 2.1.1, and so we didn't pick up the new case during the 
3-way merge. Simple fix is to add the call 

field = field.getVisibleBinding(.....) after finding the field.

Will commit fix once all tests are passing etc....
Comment 3 Adrian Colyer CLA 2004-03-18 17:40:04 EST
Tests clear. Fix committed to tree.