From ddb5eea1bf53bda27c51750b1966044df97d95a1 Mon Sep 17 00:00:00 2001 From: aclement Date: Mon, 14 Aug 2006 14:22:33 +0000 Subject: [PATCH] 133770 'call and ltw': isLocallyDefined() implemented - may not be right for all classloader hierarchies (especially non-delegating ones) - but its a start! --- .../loadtime/ClassLoaderWeavingAdaptor.java | 3 ++- .../weaver/loadtime/DefaultWeavingContext.java | 15 +++++++++++++++ .../weaver/loadtime/WeavingContextTest.java | 16 +++++++++++++++- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java index 47b9368c6..161c8f62f 100644 --- a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java +++ b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java @@ -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 } diff --git a/loadtime/src/org/aspectj/weaver/loadtime/DefaultWeavingContext.java b/loadtime/src/org/aspectj/weaver/loadtime/DefaultWeavingContext.java index 2ec089253..bd4c3280f 100644 --- a/loadtime/src/org/aspectj/weaver/loadtime/DefaultWeavingContext.java +++ b/loadtime/src/org/aspectj/weaver/loadtime/DefaultWeavingContext.java @@ -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; + } } diff --git a/loadtime/testsrc/org/aspectj/weaver/loadtime/WeavingContextTest.java b/loadtime/testsrc/org/aspectj/weaver/loadtime/WeavingContextTest.java index af2e49182..c056b9ee6 100644 --- a/loadtime/testsrc/org/aspectj/weaver/loadtime/WeavingContextTest.java +++ b/loadtime/testsrc/org/aspectj/weaver/loadtime/WeavingContextTest.java @@ -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 { -- 2.39.5