The ugly caching is for types referenced by the one you are asking to weave - the entries for the cache are resolved through the classloader via getResource calls, but your passed in bytes will override that for the class you are currently modifying. I just had a quick look and I see the 'bytes' fed into Aj.preprocess by the classpreprocessor and those are the bytes that are changed and you are returned the modified version. I'm not really sure what passing in null for the bytes means. I don't know why your pre-modified bytes aren't being processed by the weaver. Does it only happen for the second class loaded this way (and you are seeing something hanging around from the first weave) or does it also happen for the first class?
cheers, Andy On 24 January 2013 16:55, Irek M <[email protected]> wrote: > Hello, > > I'd like to enhance AspectJ Java agent processing a bit, so I > decorated ClassFileTransformer from AspectJ agent using this code in > my ClassFileTransformer: > > public synchronized byte[] transform(ClassLoader loader, final String > name, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, > byte[] code) throws IllegalClassFormatException { > code = myPreModifications(code); > code = aspectjClassFileTransformer.transform(loader, name, > classBeingRedefined, protectionDomain, code); > return myPostModifications(code); > } > > > Changes done by myPostModifications method are visible, but changes > done before AspectJ (myPreModifications) aren't visible. > I've found that AspectJ just ignores "code" parameter (i can just pass > null: aspectjClassFileTransformer.transform(loader, name, > classBeingRedefined, protectionDomain, NULL)). AspectJ seems to > perform some class caching in World.TypeMap.expendableMap, and reuses > previously loaded classes. > I tried to set World.TypeMap.useExpendableMap to false, but then > AspectJ stops working. > > How to make this preprocessing before AspectJ work? How to disable > this ugly caching? > > > Irek > _______________________________________________ > 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
