Hi, On Dec 2, 2009, at 6:11 PM, Andy Clement wrote:
> Hi Silviu, > >> I am using Aj to perform runtime weaving. Afterwards, I'm saving the weaved >> class into a cache so as to avoid the instrumentation on subsequent runs. > > You know, I'm on the verge of creating such a thing in AspectJ > itself... I would be interested to here about your approach and how > you know when to invalidate the cache, and what are you using as the > cache key (some combination of the class itself hashed or something, > plus the combination of aspects defined at the time, hashed or > something?) Great to hear this. Or not :) because I'm currently writing a paper about these things. As a cache key I use a hash of the bytecode of the unaltered class. After I compute the hash, I weave aspects to the class and save the weaved class into the cache. On subsequent program executions, I recompute the hash and retrieve the weaved version. When the list of aspects I instrument classes with changes, I invalidate the cache. Thus, after changing the list of aspects, on subsequent runs, a new cache is rebuilt. One thing I'm considering is having caches for each sequence of applied aspects so as to not start from scratch if there is a common sub sequence between what I already cached and the new list of aspects. > > If AspectJ did this itself then the only user configuration would be a > place to keep these woven classes so that they can be retrieved later. > Do you have any specific requirements for the cache in your scenario? > (or does anyone else reading this have requirements on a cache like > this?) Well, I would like to be able to retrieve them. Nothing more. A predefined place would be best. > >> Now, my problem is that I use around advices that create additional >> Class$AjcClosure. >> Is there any way I can get handle of those classes? I must mention I am >> using a java agent that would normally be called whenever a new class is >> loaded, but it appears that the Closure classes somehow escape this. > > There currently isn't a way for you to get at them I don't think - but > there have been other requests to access them, or at least be made > aware of them. This wasn't for a caching purpose but merely to avoid > clashes in the case where an attempt is made to define the same class > twice (https://bugs.eclipse.org/bugs/show_bug.cgi?id=287426). So what happens with the $AjcClosure classes? Isn't there a way I can get their bytecode? WeavingAdaptor has a method called "accept" that sounds to do just that. Also, the WeavingAdaptor constructor takes in a "GeneratedClassHandler". Is there a way I can get a hold of that handler from within "Aj"? Thanks a lot! Silviu > > Raise an enhancement request and I'll see what I can do. > > Andy > _______________________________________________ > aspectj-users mailing list > [email protected] > https://dev.eclipse.org/mailman/listinfo/aspectj-users _______________________________________________ aspectj-users mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/aspectj-users
