Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] aspectj agent decorating

> 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.

Normally it should mean NullPointerException, which would assure me
that bytes are being read. No null pointer, code just works normally.
The problem is probably in method
public BcelObjectType
org.aspectj.weaver.bcel.BcelWorld.addSourceObjectType(String
classname, byte[] bytes, boolean artificial)

It has code:
// ...
ResolvedType fromTheMap = typeMap.get(signature);
// now some checking of fromTheMap
ReferenceType nameTypeX = (ReferenceType) fromTheMap;
if (nameTypeX == null) {
    // loads nameTypeX from bytes parameter
} else {
    // uses cached nameTypeX
}

Unfortunately, disabling typeMap by replacing  typeMap.get(signature)
with null, or setting World.TypeMap.useExpendableMap to false causes
AspectJ to stop weaving any classes.

> 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?

It seems that all classes from classloader are cached this way,
probably at the moment of processing first class from that loader.


Back to the top