• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

OOPS in AspectJ

 
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why does AspectJ permit aspects to access and add members of another type? Isn't that violating OO encapsulation?
 
Author
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Adding members to another type doesn't violate encapsulation. Existing clients of that type continue to use the type as if it isn't modified. Only aspects (and other parts) that are aware of the introduced members utilize the type to provide additional functionality. As for access, by default aspects use the same access rules as Java. Specifically, aspects do not have access to private members of another type. AspectJ does have privileged aspects that can give access to private members, but its use should be (and usually is) limited to corner cases.

-Ramnivas
 
Amruth Puppala
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much Ramnivas
 
reply
    Bookmark Topic Watch Topic
  • New Topic