]> source.dussan.org Git - aspectj.git/commitdiff
133770 'call and ltw': now attempts to grab a delegate for a non-locally defined...
authoraclement <aclement>
Tue, 15 Aug 2006 09:49:59 +0000 (09:49 +0000)
committeraclement <aclement>
Tue, 15 Aug 2006 09:49:59 +0000 (09:49 +0000)
weaver/src/org/aspectj/weaver/World.java
weaver/src/org/aspectj/weaver/ltw/LTWWorld.java

index 2112f3525138818893ba80490950a3c9d3cc88df..56d65a0c34e6d08d2a12e2a44fe1205b0e661083 100644 (file)
@@ -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...
      */
index 49596ca51a30b916594d3dd6a2761f320791bf90..ff6b7b727ceedec5f6d155db80b18de4c21dd6c0 100644 (file)
@@ -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;
+       }
     
 }