Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AJDT » weaving java and javax classes(aspectj load time weaving, java and javax classes)
weaving java and javax classes [message #659504] Mon, 14 March 2011 11:06 Go to next message
Celal is currently offline CelalFriend
Messages: 7
Registered: March 2011
Junior Member
Hi all,
I'm trying to print signatures of all methods called in an application (basically the whole call tree under "main" for a single thread java application).

Now the issue is, I can't get the java.* and javax.* classes weaved.

I have read pretty much everything on the web, including using the flags "-Xset:weaveJavaPackages=true,weaveJavaxPackages=true" in my weaver options, but I just can't get this to work.

Let me give some information:
- I use load-time-weaving.
- In my aop.xml, I describe the weaver with:
<weaver options="-Xset:weaveJavaPackages=true,weaveJavaxPackages=true -verbose -debug -showWeaveInfo">
<include within="javax.*"/>
<include within="java.*"/>
<include within="*"/>
</weaver>
(yep, I shouldn't need the java and javax ones since I use *, but I'm desperate at this point Smile ).
- My aspect uses around, with this pointcut:
execution(* *(..)) && !within(MethodTracer)

I can see that my own classes are weaved and my own methods are traced, but not the javax and java ones.

I am doing the simplest thing to test this: use "System.out.println()" to see that it gets executed and my aspect is woven on it. But unfortunately this is not the case for me.

I'm sure this has come up many times before (as I said, I have read anything I could find on google), but I'm just stuck. Maybe another pair of eyes could help me..
Re: weaving java and javax classes [message #659506 is a reply to message #659504] Mon, 14 March 2011 11:15 Go to previous messageGo to next message
Celal is currently offline CelalFriend
Messages: 7
Registered: March 2011
Junior Member
I forgot to mention that:
- I use aspectj (both rt and weaver) version 1.6.11.M2 (just to make sure I have the latest and greatest build)
- I created a javax.test package with a Test class and called a method in there, and it is picked up by the aspect correctly, with the appropriate logs:
"[AppClassLoader@fabe9] debug weaving 'javax.test.Test'
- I looked at the source code of aspectjweaver, and the options "-Xset:weaveJavaPackages=true,weaveJavaxPackages=true" are there, i.e. the code to parse them are inside the code.
(and I'm given the nice warning message if I don't put them):
[AppClassLoader@fabe9] warning javax.* types are not being woven because the weaver option '-Xset:weaveJavaxPackages=true' has not been specified
[AppClassLoader@fabe9] debug cannot weave 'javax.test.Test'

So basically, it is only those classes in rt.jar that are not picked up I believe.
Thanks everyone in advance.
Re: weaving java and javax classes [message #659581 is a reply to message #659506] Mon, 14 March 2011 16:31 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 369
Registered: July 2009
Senior Member
Without knowing too much about your application, I can tell you that weaving jdk classes is very, very tricky. Consider this: the weaver itself is Java byte code and so needs to load up some JDK classes before weaving can start. If you are weaving into any of those JDK classes that the weaver pre-loads, they cannot get woven.

The first workaround is a pain. You can try compile time weaving for the JDK. But this of course means that you need to use a specially modified JDK when running your app.

Alternatively (and this is probably something you don't want to hear either), just don't do it. Rather than using execution pointcuts, you can use call pointcuts and you won't require weaving into the JDK.

I wish there were a better answer for you, but load time weaving of the JDK is not what AspectJ was designed to do.
Re: weaving java and javax classes [message #659624 is a reply to message #659581] Mon, 14 March 2011 20:25 Go to previous messageGo to next message
Celal is currently offline CelalFriend
Messages: 7
Registered: March 2011
Junior Member
Yep, what you say makes sense Andrew, thank you for your advice. I actually wanted to use profilers to get the information I need (I need to get the call graph of the running program), but after playing with a few profilers, I thought they are too heavy-weight for my purpose. So I thought I could get quick results using AOP.

So, is there any other way that you can think of for me to get the call graph, including those methods called in the jdk? I guess I may have to go back to using one of those profilers.
Re: weaving java and javax classes [message #659636 is a reply to message #659624] Mon, 14 March 2011 21:16 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 369
Registered: July 2009
Senior Member
AspectJ can't help you with this, unless of course you choose to ignore JDK methods or do compile time weaving with the caveates described above.
Re: weaving java and javax classes [message #659893 is a reply to message #659636] Tue, 15 March 2011 22:23 Go to previous message
Celal is currently offline CelalFriend
Messages: 7
Registered: March 2011
Junior Member
Thanks Andrew, I decided to ignore the JDK classes and see if it has any affect on the research I do.
Previous Topic:JST refactory participation
Next Topic:ClassCircularityError
Goto Forum:
  


Current Time: Sun Nov 23 06:09:04 GMT 2014

Powered by FUDForum. Page generated in 0.03448 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software