• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Dragan Stankovic
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
So, does that mean that I can use around advice to modify their behavior?

 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • 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
  • 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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic