Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Instrumenting JDKs

Hi!

Concerning JDK instrumentation, some work has been done in our research group 
[1] on that issue. We are mainly focusing on dynamic analysis aspects (for 
profiling, debugging) that needs to be woven in every class. From our 
experience the 2 main issues arising from the instrumentation of the JDK are:
- during the bootstrapping phase the JVM expects to load the first classes in 
a given order. If they are woven, additional dependecies (e.g. to AspectJ 
runtime classes) are added and may break that order and causes a (pretty bad) 
JVM crash.
- advice usually uses JDK classes as well, and this may cause infinite 
recursions when they call back into woven JDK classes.

We developed a system [2] that keeps 2 versions of each methods (original and 
woven with aspects) with a switch that executes woven code and fall backs to 
original code during the bootstrapping phase and when in the control-flow of 
an advice. Technical details are available in our publication "Aspect Weaving 
in Standard Java Class Libraries" [3]. For further information please contact 
us.


[1] http://dag.inf.usi.ch/
[2] http://www.inf.usi.ch/projects/ferrari/MAJOR.html
[3] http://www.inf.usi.ch/faculty/binder/documents/pppj08.pdf

Cheers,
Philippe

On Thursday, March 17, 2011 03:14:10 pm Tiago Espinha wrote:
> Just for future reference, if other people come across the same, I have
> indeed managed to successfully instrument rt.jar. The exceptions I was
> experiencing had actually to do with some double-weaving that I was doing.
> I was weaving the rt.jar but I had forgotten that I had also weaved a
> jaxws library which I was also using.
> 
> That was causing some sort of problem, but it doesn't really matter in the
> end as I didn't mean to have the jaxws library woven at this point.
> 
> Thanks again for the clarification!
> 
> Cheers,
> Tiago
> 
> 2011/3/16 Tiago Espinha <tiago@xxxxxxxxxx>
> 
> > A-ha! When I faced those issues, I googled and I found a lot of people
> > facing issues with weaving into the JDK so I thought it was an actual
> > limitation of AspectJ. But from what you say, it seems like the only
> > problem has to do with loadtime weaving but instrumenting a JAR should
> > be fine.
> > 
> > Well, that's certainly good news and tomorrow I'll give it another try.
> > Maybe this exception I'm facing has to do with something else...
> > 
> > Anyway, thanks a lot!
> > 
> > Cheers,
> > Tiago
> > 
> > 
> > 2011/3/16 Andy Clement <andrew.clement@xxxxxxxxx>
> > 
> >> > What makes it so different from instrumenting any other JAR?
> >> 
> >> These classes are loaded by a classloader that does not get a chance
> >> to attach a weaver, when using javaagent - so loadtime weaving isn't
> >> possible.  With care, you can do what you have done, weave rt.jar and
> >> use that new version.  The trouble is that it can be easy to cause
> >> yourself problems if you, for example, weave String but also use
> >> String (perhaps inadvertently) in your aspect - easy to create
> >> stackoverflow issues.  I don't know why you have a NoSuchMethodError
> >> though.
> >> 
> >> But I know others have done the weaving successfully - hopefully one
> >> of them can follow up my post :)
> >> 
> >> cheers
> >> Andy
> >> 
> >> On 16 March 2011 06:19, Tiago Espinha <tiago@xxxxxxxxxx> wrote:
> >> > Hi all,
> >> > I've been looking around the Internet, and it seems like it's
> >> > impossible
> >> 
> >> (or
> >> 
> >> > at least failure-prone) to weave aspects into JDKs. I did it myself -
> >> > I instrumented the rt.jar file from the latest Oracle JDK for Linux -
> >> > and, whilst the weaving goes seemingly fine, I hit failures on
> >> > runtime with
> >> 
> >> such
> >> 
> >> > exceptions as NoSuchMethodError, relating to the aspect I wove.
> >> > What I cannot understand is the reason why JDK instrumentation is
> >> > impossible. What makes it so different from instrumenting any other
> >> > JAR?
> >> 
> >> And
> >> 
> >> > does anyone know if there are workarounds to it?
> >> > Thanks in advance!
> >> > Cheers,
> >> > Tiago
> >> > _______________________________________________
> >> > aspectj-users mailing list
> >> > aspectj-users@xxxxxxxxxxx
> >> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >> 
> >> _______________________________________________
> >> aspectj-users mailing list
> >> aspectj-users@xxxxxxxxxxx
> >> https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top