[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] questions about WeavingURLClassLoader

having a look at the code of the WeavingURLClassLoader a couple of doubts 

The method defineClass does the following:

	protected Class defineClass(String name, byte[] b, CodeSource cs) throws 
IOException {
		/* Avoid recursion during adaptor initialization */
		if (!initializingAdaptor) {
			if (adaptor == null && !initializingAdaptor) {
			try {
				b = adaptor.weaveClass(name,b,false);
			catch (AbortException ex) {...}
			catch (Throwable th) {...}
		Class clazz = super.defineClass(name, b, cs);
		return clazz;

So the adaptor is used to obtain a byte array for the new weaved class, and 
then the base class of the loader (that could be the root class loader) is 
used to define the class with the byte array. Doing this the same class 
cannot be weaved again with another aspect later, because it is not the 
weaver class loader that is defining the class, but its parent. In other 
words, even with multiple WeavingClassLoaders the same class (i.e., the same 
class name) could not have different implementations, right? 

Moreover, in the ClassLoaderWeavingAdaptor, the aspects definition are built 
starting from the xml file (aop.xml) in the method parseDefinition. Is there 
a way to add aspects without having them defined in the xml file? The reason 
for that is that I will know which aspect to weave to a class only at 
run-time, so I cannot produce an xml file before.