Project: AspectJ
Bug 96371 Patch to support loading aop.xml properly
Reported: 2005-05-23 17:22:52 | Status: resolved fixed

AspectJ 5 load-time weaving in CVS HEAD isn't loading aop.xml files properly from a jar file without specifying the global -D flag. The following patch fixes the problem for me so I can load aop.xml files from jars on the classpath without a global flag: ClassLoaderWeavingAdaptor.java:109: - Enumeration xmls = loader.getResources("/META-INF/aop.xml"); + Enumeration xmls = loader.getResources("META-INF/aop.xml"); I.e., getResources doesn't work with a leading separator, at least not on the Sun VM or JRockIt on Windows. Writing a unit test for this would require significant changes to the loadtime module, so I wrote a standalone test of the API: public class TestApi extends TestCase { public void testLoadResource() throws Exception { URL urlList[] = { new URL ("file:testsrc/org/aspectj/weaver/loadtime/test/sample.jar") }; ClassLoader loader = new URLClassLoader(urlList); Enumeration xmls = loader.getResources("META-INF/aop.xml"); //this version fails: //Enumeration xmls = loader.getResources("/META-INF/aop.xml"); assertTrue(xmls.hasMoreElements()); } }

Files changed in fix:
loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java loadtime5/java5-src/org/aspectj/weaver/loadtime/ClassPreProcessorAgentAdapter.java tests/java5/ataspectj/ataspectj/SingletonAspectBindingsTest.java