package org.aspectj.weaver;
+import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import org.aspectj.bridge.context.PinpointingMessageHandler;
import org.aspectj.util.IStructureModel;
import org.aspectj.weaver.UnresolvedType.TypeKind;
+import org.aspectj.weaver.patterns.Declare;
import org.aspectj.weaver.patterns.DeclareAnnotation;
import org.aspectj.weaver.patterns.DeclareParents;
import org.aspectj.weaver.patterns.DeclarePrecedence;
protected boolean bcelRepositoryCaching = xsetBCEL_REPOSITORY_CACHING_DEFAULT.equalsIgnoreCase("true");
private boolean fastMethodPacking = false;
private int itdVersion = 2; // defaults to 2nd generation itds
+
+ // Minimal Model controls whether model entities that are not involved in relationships are deleted post-build
+ private boolean minimalModel = false;
+
private boolean completeBinaryTypes = false;
private boolean overWeaving = false;
public boolean forDEBUG_structuralChangesCode = false;
/**
* A list of RuntimeExceptions containing full stack information for every type we couldn't find.
*/
- private List dumpState_cantFindTypeExceptions = null;
+ private List<RuntimeException> dumpState_cantFindTypeExceptions = null;
/**
* Play God. On the first day, God created the primitive types and put them in the type map.
// MessageUtil.error(messageHandler,
// WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE,ty.getName()));
if (dumpState_cantFindTypeExceptions == null) {
- dumpState_cantFindTypeExceptions = new ArrayList();
+ dumpState_cantFindTypeExceptions = new ArrayList<RuntimeException>();
}
if (dumpState_cantFindTypeExceptions.size() < 100) { // limit growth
dumpState_cantFindTypeExceptions.add(new RuntimeException("Can't find type " + ty.getName()));
Xpinpoint = b;
}
+ public boolean isMinimalModel() {
+ ensureAdvancedConfigurationProcessed();
+ return minimalModel;
+ }
+
public void setBehaveInJava5Way(boolean b) {
behaveInJava5Way = b;
}
public final static String xsetITD_VERSION_ORIGINAL = "1";
public final static String xsetITD_VERSION_2NDGEN = "2";
public final static String xsetITD_VERSION_DEFAULT = xsetITD_VERSION_2NDGEN;
+ public final static String xsetMINIMAL_MODEL = "minimalModel";
public boolean isInJava5Mode() {
return behaveInJava5Way;
final Map<String, ResolvedType> tMap = new HashMap<String, ResolvedType>();
// Map of types that may be ejected from the cache if we need space
- final Map expendableMap = Collections.synchronizedMap(new WeakHashMap());
+ final Map<String, Reference<ResolvedType>> expendableMap = Collections
+ .synchronizedMap(new WeakHashMap<String, Reference<ResolvedType>>());
private final World w;
private boolean memoryProfiling = false;
private int maxExpendableMapSize = -1;
private int collectedTypes = 0;
- private final ReferenceQueue rq = new ReferenceQueue();
+ private final ReferenceQueue<ResolvedType> rq = new ReferenceQueue<ResolvedType>();
- private static Trace trace = TraceFactory.getTraceFactory().getTrace(World.TypeMap.class);
+ // private static Trace trace = TraceFactory.getTraceFactory().getTrace(World.TypeMap.class);
TypeMap(World w) {
demotionSystemActive = w.isDemotionActive();
}
// For testing
- public Map getExpendableMap() {
+ public Map<String, Reference<ResolvedType>> getExpendableMap() {
return expendableMap;
}
// For testing
- public Map getMainMap() {
+ public Map<String, ResolvedType> getMainMap() {
return tMap;
}
tMap.remove(key);
if (!expendableMap.containsKey(key)) {
if (policy == USE_SOFT_REFS) {
- expendableMap.put(key, new SoftReference(type));
+ expendableMap.put(key, new SoftReference<ResolvedType>(type));
} else {
- expendableMap.put(key, new WeakReference(type));
+ expendableMap.put(key, new WeakReference<ResolvedType>(type));
}
}
demotionCounter++;
// Dont use reference queue for tracking if not profiling...
if (policy == USE_WEAK_REFS) {
if (memoryProfiling) {
- expendableMap.put(key, new WeakReference(type, rq));
+ expendableMap.put(key, new WeakReference<ResolvedType>(type, rq));
} else {
- expendableMap.put(key, new WeakReference(type));
+ expendableMap.put(key, new WeakReference<ResolvedType>(type));
}
} else if (policy == USE_SOFT_REFS) {
if (memoryProfiling) {
- expendableMap.put(key, new SoftReference(type, rq));
+ expendableMap.put(key, new SoftReference<ResolvedType>(type, rq));
} else {
- expendableMap.put(key, new SoftReference(type));
+ expendableMap.put(key, new SoftReference<ResolvedType>(type));
}
- } else {
- expendableMap.put(key, type);
+ // } else {
+ // expendableMap.put(key, type);
}
if (memoryProfiling && expendableMap.size() > maxExpendableMapSize) {
maxExpendableMapSize = expendableMap.size();
ResolvedType ret = tMap.get(key);
if (ret == null) {
if (policy == USE_WEAK_REFS) {
- WeakReference ref = (WeakReference) expendableMap.get(key);
+ WeakReference<ResolvedType> ref = (WeakReference<ResolvedType>) expendableMap.get(key);
if (ref != null) {
- ret = (ResolvedType) ref.get();
+ ret = ref.get();
}
} else if (policy == USE_SOFT_REFS) {
- SoftReference<ResolvedType> ref = (SoftReference) expendableMap.get(key);
+ SoftReference<ResolvedType> ref = (SoftReference<ResolvedType>) expendableMap.get(key);
if (ref != null) {
ret = ref.get();
}
- } else {
- return (ResolvedType) expendableMap.get(key);
+ // } else {
+ // return (ResolvedType) expendableMap.get(key);
}
}
return ret;
ResolvedType ret = tMap.remove(key);
if (ret == null) {
if (policy == USE_WEAK_REFS) {
- WeakReference wref = (WeakReference) expendableMap.remove(key);
+ WeakReference<ResolvedType> wref = (WeakReference<ResolvedType>) expendableMap.remove(key);
if (wref != null) {
- ret = (ResolvedType) wref.get();
+ ret = wref.get();
}
} else if (policy == USE_SOFT_REFS) {
- SoftReference wref = (SoftReference) expendableMap.remove(key);
+ SoftReference<ResolvedType> wref = (SoftReference<ResolvedType>) expendableMap.remove(key);
if (wref != null) {
- ret = (ResolvedType) wref.get();
+ ret = wref.get();
}
- } else {
- ret = (ResolvedType) expendableMap.remove(key);
+ // } else {
+ // ret = (ResolvedType) expendableMap.remove(key);
}
}
return ret;
private static class AspectPrecedenceCalculator {
private final World world;
- private final Map cachedResults;
+ private final Map<PrecedenceCacheKey, Integer> cachedResults;
public AspectPrecedenceCalculator(World forSomeWorld) {
world = forSomeWorld;
- cachedResults = new HashMap();
+ cachedResults = new HashMap<PrecedenceCacheKey, Integer>();
}
/**
public int compareByPrecedence(ResolvedType firstAspect, ResolvedType secondAspect) {
PrecedenceCacheKey key = new PrecedenceCacheKey(firstAspect, secondAspect);
if (cachedResults.containsKey(key)) {
- return ((Integer) cachedResults.get(key)).intValue();
+ return (cachedResults.get(key)).intValue();
} else {
int order = 0;
DeclarePrecedence orderer = null; // Records the declare
// precedence statement that
// gives the first ordering
- for (Iterator i = world.getCrosscuttingMembersSet().getDeclareDominates().iterator(); i.hasNext();) {
+ for (Iterator<Declare> i = world.getCrosscuttingMembersSet().getDeclareDominates().iterator(); i.hasNext();) {
DeclarePrecedence d = (DeclarePrecedence) i.next();
int thisOrder = d.compare(firstAspect, secondAspect);
if (thisOrder != 0) {
}
public Integer getPrecedenceIfAny(ResolvedType aspect1, ResolvedType aspect2) {
- return (Integer) cachedResults.get(new PrecedenceCacheKey(aspect1, aspect2));
+ return cachedResults.get(new PrecedenceCacheKey(aspect1, aspect2));
}
public int compareByPrecedenceAndHierarchy(ResolvedType firstAspect, ResolvedType secondAspect) {
// --- I would rather stash this against a reference type - but we don't
// guarantee referencetypes are unique for
// so we can't :(
- private final Map workInProgress1 = new HashMap();
+ private final Map<Class<?>, TypeVariable[]> workInProgress1 = new HashMap<Class<?>, TypeVariable[]>();
- public TypeVariable[] getTypeVariablesCurrentlyBeingProcessed(Class baseClass) {
- return (TypeVariable[]) workInProgress1.get(baseClass);
+ public TypeVariable[] getTypeVariablesCurrentlyBeingProcessed(Class<?> baseClass) {
+ return workInProgress1.get(baseClass);
}
- public void recordTypeVariablesCurrentlyBeingProcessed(Class baseClass, TypeVariable[] typeVariables) {
+ public void recordTypeVariablesCurrentlyBeingProcessed(Class<?> baseClass, TypeVariable[] typeVariables) {
workInProgress1.put(baseClass, typeVariables);
}
- public void forgetTypeVariablesCurrentlyBeingProcessed(Class baseClass) {
+ public void forgetTypeVariablesCurrentlyBeingProcessed(Class<?> baseClass) {
workInProgress1.remove(baseClass);
}
itdVersion = 1;
}
+ s = p.getProperty(xsetMINIMAL_MODEL, "false");
+ if (s.equalsIgnoreCase("true")) {
+ minimalModel = true;
+ }
+
s = p.getProperty(xsetFAST_PACK_METHODS, "true");
fastMethodPacking = s.equalsIgnoreCase("true");
return null;
}
- public Map getFixed() {
+ public Map<String, ResolvedType> getFixed() {
return typeMap.tMap;
}
- public Map getExpendable() {
+ public Map<String, Reference<ResolvedType>> getExpendable() {
return typeMap.expendableMap;
}