wood burning stoves 2.0*
The moose likes Spring and the fly likes Is it possible to instrument classess from java or javax package with AspectJ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Is it possible to instrument classess from java or javax package with AspectJ?" Watch "Is it possible to instrument classess from java or javax package with AspectJ?" New topic
Author

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

Dragan Stankovic
Ranch Hand

Joined: Oct 14, 2008
Posts: 33
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?


http://www.expertaya.com
Dragan Stankovic
Ranch Hand

Joined: Oct 14, 2008
Posts: 33
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

Joined: Feb 05, 2001
Posts: 17249
    
    6

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.


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Dragan Stankovic
Ranch Hand

Joined: Oct 14, 2008
Posts: 33
So, does that mean that I can use around advice to modify their behavior?

Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
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.


SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
Dragan Stankovic
Ranch Hand

Joined: Oct 14, 2008
Posts: 33
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!
 
 
subject: Is it possible to instrument classess from java or javax package with AspectJ?
 
Similar Threads
Intercepting methods call in a web application
How do I have a child table when the parent has a composite key
Head First Java - MIDI question
listening to method invocation
Library to output/log the debug trace of programmer's source code