From c320a727941abbee6367d25e4f343ea174c6b2c6 Mon Sep 17 00:00:00 2001 From: aclement Date: Thu, 15 Jul 2010 23:23:03 +0000 Subject: [PATCH] 278496 --- .../weaver/AbstractReferenceTypeDelegate.java | 7 +++ .../aspectj/weaver/ReferenceTypeDelegate.java | 4 ++ .../src/org/aspectj/weaver/World.java | 45 ++++++++++++++----- 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/AbstractReferenceTypeDelegate.java b/org.aspectj.matcher/src/org/aspectj/weaver/AbstractReferenceTypeDelegate.java index 7d3105963..f73504927 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/AbstractReferenceTypeDelegate.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/AbstractReferenceTypeDelegate.java @@ -144,4 +144,11 @@ public abstract class AbstractReferenceTypeDelegate implements ReferenceTypeDele } + public boolean isWeavable() { + return false; + } + + public boolean hasBeenWoven() { + return false; + } } \ No newline at end of file diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ReferenceTypeDelegate.java b/org.aspectj.matcher/src/org/aspectj/weaver/ReferenceTypeDelegate.java index f13ba87cc..2f307d363 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/ReferenceTypeDelegate.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/ReferenceTypeDelegate.java @@ -136,4 +136,8 @@ public interface ReferenceTypeDelegate { */ public void ensureConsistent(); + public boolean isWeavable(); + + public boolean hasBeenWoven(); + } \ No newline at end of file diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/World.java b/org.aspectj.matcher/src/org/aspectj/weaver/World.java index dcadd5931..9457e3e02 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/World.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/World.java @@ -442,7 +442,8 @@ public abstract class World implements Dump.INode { } else if (ty.isGenericType()) { // ======= generic types ====================== - ReferenceType genericType = (ReferenceType) resolveGenericTypeFor(ty, false); + ResolvedType rt = resolveGenericTypeFor(ty, false); + ReferenceType genericType = (ReferenceType) rt; return genericType; } else if (ty.isGenericWildcard()) { @@ -1029,6 +1030,10 @@ public abstract class World implements Dump.INode { return tMap; } + public int demote() { + return demote(false); + } + /** * Go through any types added during the previous file weave. If any are suitable for demotion, then put them in the * expendable map where GC can claim them at some point later. Demotion means: the type is not an aspect, the type is not @@ -1037,24 +1042,38 @@ public abstract class World implements Dump.INode { * * @return number of types demoted */ - public int demote() { - if (!demotionSystemActive) { + public int demote(boolean atEndOfCompile) { + if (!demotionSystemActive || (!atEndOfCompile && !w.isLoadtimeWeaving())) { return 0; } int demotionCounter = 0; + boolean ctw = !w.isLoadtimeWeaving(); for (String key : addedSinceLastDemote) { ResolvedType type = tMap.get(key); if (type != null && !type.isAspect() && !type.equals(UnresolvedType.OBJECT) && !type.isPrimitiveType()) { + if (type.isParameterizedOrRawType()) { + type = type.getGenericType(); + } List typeMungers = type.getInterTypeMungers(); if (typeMungers == null || typeMungers.size() == 0) { - tMap.remove(key); - if (!expendableMap.containsKey(key)) { - if (policy == USE_SOFT_REFS) { - expendableMap.put(key, new SoftReference(type)); - } else { - expendableMap.put(key, new WeakReference(type)); + ReferenceTypeDelegate delegate = ((ReferenceType) type).getDelegate(); + boolean isWeavable = delegate == null ? false : delegate.isWeavable(); + // boolean hasBeenWoven = delegate == null ? false : delegate.hasBeenWoven(); + // System.out.println("Might demote " + key + " delegate?" + (delegate == null) + " isWeavable?" + isWeavable); + // + " hasBeenWoven?" + hasBeenWoven); + + if (!ctw || !isWeavable) { // || hasBeenWoven) { + // System.out.println("Demoting " + key); + tMap.remove(key); + if (!expendableMap.containsKey(key)) { + if (policy == USE_SOFT_REFS) { + expendableMap.put(key, new SoftReference(type)); + } else { + expendableMap.put(key, new WeakReference(type)); + } } } + // } demotionCounter++; } } @@ -1142,6 +1161,7 @@ public abstract class World implements Dump.INode { } else { if (demotionSystemActive) { + // System.out.println("Added since last demote " + key); addedSinceLastDemote.add(key); } @@ -1422,9 +1442,11 @@ public abstract class World implements Dump.INode { MessageUtil.info("[completeBinaryTypes=true] Completion of binary types activated")); } - s = p.getProperty(xsetTYPE_DEMOTION, "true"); // default is ON + s = p.getProperty(xsetTYPE_DEMOTION, "true"); // default is: ON (for ltw) OFF (for ctw) if (s.equalsIgnoreCase("false")) { typeMap.demotionSystemActive = false; + } else if (s.equalsIgnoreCase("true") && !typeMap.demotionSystemActive) { + typeMap.demotionSystemActive = true; } s = p.getProperty(xsetOVERWEAVING, "false"); @@ -1818,4 +1840,7 @@ public abstract class World implements Dump.INode { return itdVersion; } + // if not loadtime weaving then we are compile time weaving or post-compile time weaving + public abstract boolean isLoadtimeWeaving(); + } \ No newline at end of file -- 2.39.5