From: aclement Date: Tue, 15 Aug 2006 09:49:59 +0000 (+0000) Subject: 133770 'call and ltw': now attempts to grab a delegate for a non-locally defined... X-Git-Tag: post_pr_153572~16 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=58a3e87818ffaba69df25e4c0601b99f2931a31f;p=aspectj.git 133770 'call and ltw': now attempts to grab a delegate for a non-locally defined type, giving the super-loader chance to weave a type with ITDs. --- diff --git a/weaver/src/org/aspectj/weaver/World.java b/weaver/src/org/aspectj/weaver/World.java index 2112f3525..56d65a0c3 100644 --- a/weaver/src/org/aspectj/weaver/World.java +++ b/weaver/src/org/aspectj/weaver/World.java @@ -268,23 +268,8 @@ public abstract class World implements Dump.INode { if (!allowMissing && ret.isMissing()) { ret = handleRequiredMissingTypeDuringResolution(ty); } - - if (completeBinaryTypes && needsCompletion() && isLocallyDefined(ret.getName())) { - if (typeCompletionInProgress) { - typesForCompletion.add(ret); - } else { - try { - typeCompletionInProgress=true; - completeType(ret); - } finally { - typeCompletionInProgress=false; - } - while (typesForCompletion.size()!=0) { - ResolvedType rt = (ResolvedType)typesForCompletion.get(0); - completeType(rt); - typesForCompletion.remove(0); - } - } + if (completeBinaryTypes) { + completeBinaryType(ret); } } @@ -294,25 +279,12 @@ public abstract class World implements Dump.INode { } return ret; } - - // --- these methods are for supporting loadtime weaving with inter type declarations - // the idea is that when types are resolved, we give the world a chance to say whether - // it needs to 'finish them off' - ie. attach type mungers for ITDs. These types won't - // actually get woven at this time, they will merely have type mungers attached to them - // for the purposes of answering questions like 'what is your supertype?' correctly. - - /** - * return true if types need completing when getting resolved - overridden by subtypes. - */ - protected boolean needsCompletion() { - return false; - } - + /** * Called when a type is resolved - enables its type hierarchy to be finished off before we * proceed */ - protected void completeType(ResolvedType ret) {} + protected void completeBinaryType(ResolvedType ret) {} /** @@ -322,14 +294,7 @@ public abstract class World implements Dump.INode { public boolean isLocallyDefined(String classname) { return false; } - - // One type is completed at a time, if multiple need doing then they - // are queued up - private boolean typeCompletionInProgress = false; - private List/*ResolvedType*/typesForCompletion = new ArrayList(); - - // --- - + /** * We tried to resolve a type and couldn't find it... */ diff --git a/weaver/src/org/aspectj/weaver/ltw/LTWWorld.java b/weaver/src/org/aspectj/weaver/ltw/LTWWorld.java index 49596ca51..ff6b7b727 100644 --- a/weaver/src/org/aspectj/weaver/ltw/LTWWorld.java +++ b/weaver/src/org/aspectj/weaver/ltw/LTWWorld.java @@ -13,8 +13,10 @@ package org.aspectj.weaver.ltw; import java.lang.ref.Reference; import java.lang.ref.WeakReference; +import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.aspectj.bridge.IMessageHandler; @@ -46,7 +48,8 @@ import org.aspectj.weaver.reflect.ReflectionWorld; */ public class LTWWorld extends BcelWorld implements IReflectionWorld { - private AnnotationFinder annotationFinder; + + private AnnotationFinder annotationFinder; private ClassLoader loader; // weavingContext? private IWeavingContext weavingContext; @@ -186,8 +189,38 @@ public class LTWWorld extends BcelWorld implements IReflectionWorld { public boolean isRunMinimalMemory() { return true; } + + + // One type is completed at a time, if multiple need doing then they + // are queued up + private boolean typeCompletionInProgress = false; + private List/*ResolvedType*/typesForCompletion = new ArrayList(); - protected void completeType(ResolvedType ret) { + protected void completeBinaryType(ResolvedType ret) { + if (isLocallyDefined(ret.getName())) { + if (typeCompletionInProgress) { + typesForCompletion.add(ret); + } else { + try { + typeCompletionInProgress=true; + completeHierarchyForType(ret); + } finally { + typeCompletionInProgress=false; + } + while (typesForCompletion.size()!=0) { + ResolvedType rt = (ResolvedType)typesForCompletion.get(0); + completeHierarchyForType(rt); + typesForCompletion.remove(0); + } + } + } else { + if (!ret.needsModifiableDelegate()) { + ret = completeNonLocalType(ret); + } + } + } + + private void completeHierarchyForType(ResolvedType ret) { getLint().typeNotExposedToWeaver.setSuppressed(true); weaveInterTypeDeclarations(ret); getLint().typeNotExposedToWeaver.setSuppressed(false); @@ -200,5 +233,16 @@ public class LTWWorld extends BcelWorld implements IReflectionWorld { public boolean isLocallyDefined(String classname) { return weavingContext.isLocallyDefined(classname); } + + protected ResolvedType completeNonLocalType(ResolvedType ret) { + if (ret.isMissing()) return ret; // who knows ?!? + ResolvedType toResolve = ret; + if (ret.isParameterizedType() || ret.isGenericType()) { + toResolve = toResolve.getGenericType(); + } + ReferenceTypeDelegate rtd = resolveReflectionTypeDelegate((ReferenceType)toResolve,loader); + ((ReferenceType)ret).setDelegate(rtd); + return ret; + } }