Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] (no subject)

Hi all!

Is it possible to use LoadTimeWeaving with the -javaagent option while a custom classloader should be used?

More detailed:
There is a 3party.jar that specifies a 3PartyClassLoader.class. 
This is going to be used to load classes from an app.jar every time the app.jar is executed.
So a 
java -jar app.jar 
call would invoke the 3PartyClassLoader.class from the 3party.jar to load the classes from app.jar.
No problem! The java accessibility technology provides this.

Now I have an aspectLib.jar that I'd like to weave into the app.jar during load-time.
So I run the app.jar with the 
java -javaagent:aspectjweaver.jar -jar app.jar
This fails! The classes within the 3party.jar receive a ClassDefNotFound exception while trying to access classes within the woven app.jar.

I assume that the agent within aspectjweaver.jar loads the classes and aspects that are to be woven with a special classloader. 
This would happen prior to the call of the 3party.jar through the java accessibilty framework because the premain method of the aspectjweaver's agent would be called really early! Once the classes are loaded they live in the namespace of the agents classloader thus they'd be unreachable for things that are loaded with the 3partyClassLoader.
Is that somehow right or understandable? ;)

Does someone has experiences with these custom-classloader-meets-load-time-weaving things?


Back to the top