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);
}
}
}
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) {}
/**
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...
*/
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;
*/
public class LTWWorld extends BcelWorld implements IReflectionWorld {
- private AnnotationFinder annotationFinder;
+
+ private AnnotationFinder annotationFinder;
private ClassLoader loader; // weavingContext?
private IWeavingContext weavingContext;
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);
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;
+ }
}