• 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
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Is it possible to instrument classess from java or javax package with AspectJ?

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've tried a couple of AspectJ examples recently and I liked what they allowed me to do. Then I tried to instrument some java swing and java core classes (I was just curious how stuff works from inside) and I failed to do that. Is this forbidden on purpose (e.g. security reasons) or there is a workaround... What if I really need to do something like that, is it possible?
 
Dragan Stankovic
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

What if I really need to do something like that, is it possible?


This sentence is especially meant for discussion because what I meant with it is to ask the book author if AspectJ is the best solution for this kind of a problem.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, AspectJ can instrument all those classes. That is why AspectJ is so very powerful. that you can instrument classes that your don't have the source code too.

But with this power comes responsibility.
 
Dragan Stankovic
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, does that mean that I can use around advice to modify their behavior?

 
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm no expert in AOP. But I cannot think of a reason why we cannot apply AspectJ to classes in java or javax package.

There is no anything special about classes in java or javax, actually you *can* create java or javax package in your own project, it is just a name.
 
Dragan Stankovic
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok. You are right. I finally found the explanation here: http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg09350.html

Before that I encountered some misleading pages, mentioning dynamic weaving, security, etc., and because I am relatively new to the subject I falsely assumed that this is related to security. Since I wasn't sure that I understand things correctly I've decided to check that by posting question here. This proved as a good decision at the end (I found the answer)

Thanks!
 
reply
    Bookmark Topic Watch Topic
  • New Topic