]> source.dussan.org Git - aspectj.git/commitdiff
133770 'call and ltw': isLocallyDefined() implemented - may not be right for all...
authoraclement <aclement>
Mon, 14 Aug 2006 14:22:33 +0000 (14:22 +0000)
committeraclement <aclement>
Mon, 14 Aug 2006 14:22:33 +0000 (14:22 +0000)
loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
loadtime/src/org/aspectj/weaver/loadtime/DefaultWeavingContext.java
loadtime/testsrc/org/aspectj/weaver/loadtime/WeavingContextTest.java

index 47b9368c60547659b13c24e86d8bf16bc825b635..161c8f62f7420f2261f94a36f99477d53133b466 100644 (file)
@@ -130,7 +130,8 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
         }
         
         bcelWorld = new LTWWorld(
-                classLoader, getMessageHandler(), new ICrossReferenceHandler() {
+                       classLoader, weavingContext, // TODO when the world works in terms of the context, we can remove the loader...
+                       getMessageHandler(), new ICrossReferenceHandler() {
                     public void addCrossReference(ISourceLocation from, ISourceLocation to, IRelationship.Kind kind, boolean runtimeTest) {
                         ;// for tools only
                     }
index 2ec0892532c908975bf7be1df0791d529d97f9d7..bd4c3280f626634fd00cfd0428c3f8cb1a8b4b49 100644 (file)
@@ -78,4 +78,19 @@ public class DefaultWeavingContext implements IWeavingContext {
        public String getSuffix () {
                return getClassLoaderName();
        }
+
+       public boolean isLocallyDefined(String classname) {
+        String asResource = classname.replace('.', '/').concat(".class");
+
+        URL localURL = loader.getResource(asResource);
+        if (localURL == null) return false;
+
+               boolean isLocallyDefined = true;
+        ClassLoader parent = loader.getParent();
+        if (parent != null) {
+            URL parentURL = parent.getResource(asResource);
+            if (localURL.equals(parentURL)) isLocallyDefined =  false;
+        } 
+        return isLocallyDefined;
+       }
 }
index af2e49182a58f09bf6fa82ba7761b58c3597a3c6..c056b9ee6acb2145e7d263b6eb279b70d9fa35dc 100644 (file)
@@ -142,7 +142,21 @@ public class WeavingContextTest extends TestCase {
                public Enumeration getResources(String name) throws IOException {
                        return loader.getResources(name);
                }
-               
+
+               public boolean isLocallyDefined(String classname) {
+               String asResource = classname.replace('.', '/').concat(".class");
+
+               URL localURL = loader.getResource(asResource);
+               if (localURL == null) return false;
+
+                       boolean isLocallyDefined = true;
+               ClassLoader parent = loader.getParent();
+               if (parent != null) {
+                   URL parentURL = parent.getResource(asResource);
+                   if (localURL.equals(parentURL)) isLocallyDefined =  false;
+               } 
+               return isLocallyDefined;
+               }
        }
 
        protected void setUp() throws Exception {