diff options
author | Andy Clement <andrew.clement@gmail.com> | 2013-01-25 16:54:33 -0800 |
---|---|---|
committer | Andy Clement <andrew.clement@gmail.com> | 2013-01-25 16:54:33 -0800 |
commit | f1a8813c3b200f7564f5247b4f02143fde35f0c6 (patch) | |
tree | 8392252b86c788c05eb027308ad3e555c688b1c0 /org.aspectj.matcher | |
parent | 8dc8d1e0b897d9ab515ed3d99abaee930b45c9d5 (diff) | |
download | aspectj-f1a8813c3b200f7564f5247b4f02143fde35f0c6.tar.gz aspectj-f1a8813c3b200f7564f5247b4f02143fde35f0c6.zip |
390269: fix for gc'd raw type refs
Diffstat (limited to 'org.aspectj.matcher')
-rw-r--r-- | org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java | 7 | ||||
-rw-r--r-- | org.aspectj.matcher/src/org/aspectj/weaver/World.java | 23 |
2 files changed, 17 insertions, 13 deletions
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java b/org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java index c8b1c777f..6eeaf1396 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java @@ -43,6 +43,8 @@ public class ReferenceType extends ResolvedType { * For parameterized types (or the raw type) - this field points to the actual reference type from which they are derived. */ ReferenceType genericType = null; + + ReferenceType rawType = null; // generic types have a pointer back to their raw variant (prevents GC of the raw from the typemap!) ReferenceTypeDelegate delegate = null; int startPos = 0; @@ -147,6 +149,7 @@ public class ReferenceType extends ResolvedType { public ReferenceType(UnresolvedType genericType, World world) { super(genericType.getSignature(), world); typeKind = TypeKind.GENERIC; + this.typeVariables=genericType.typeVariables; } @Override @@ -428,7 +431,6 @@ public class ReferenceType extends ResolvedType { return true; } } - if (this == other) { return true; } @@ -985,6 +987,9 @@ public class ReferenceType extends ResolvedType { if (typeKind == TypeKind.RAW) { genericType.addDependentType(this); } + if (isRawType()) { + genericType.rawType = this; + } if (this.isRawType() && rt.isRawType()) { new RuntimeException("PR341926 diagnostics: Incorrect setup for a generic type, raw type should not point to raw: " + this.getName()).printStackTrace(); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/World.java b/org.aspectj.matcher/src/org/aspectj/weaver/World.java index 960b05975..043d94e82 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/World.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/World.java @@ -475,13 +475,9 @@ public abstract class World implements Dump.INode { simpleOrRawType.setNeedsModifiableDelegate(true); } ReferenceTypeDelegate delegate = resolveDelegate(simpleOrRawType); - // 117854 - // if (delegate == null) return ResolvedType.MISSING; + if (delegate == null) { - return new MissingResolvedTypeWithKnownSignature(ty.getSignature(), erasedSignature, this);// ResolvedType - // . - // MISSING - // ; + return new MissingResolvedTypeWithKnownSignature(ty.getSignature(), erasedSignature, this); } if (delegate.isGeneric() && behaveInJava5Way) { @@ -493,14 +489,10 @@ public abstract class World implements Dump.INode { + simpleOrRawType.getName()); } ReferenceType genericType = makeGenericTypeFrom(delegate, simpleOrRawType); - // name = - // ReferenceType.fromTypeX(UnresolvedType.forRawTypeNames( - // ty.getName()),this); simpleOrRawType.setDelegate(delegate); genericType.setDelegate(delegate); simpleOrRawType.setGenericType(genericType); return simpleOrRawType; - } else { // ======== simple type ========= simpleOrRawType.setDelegate(delegate); @@ -1020,6 +1012,7 @@ public abstract class World implements Dump.INode { /* * Map of types in the world, can have 'references' to expendable ones which can be garbage collected to recover memory. An * expendable type is a reference type that is not exposed to the weaver (ie just pulled in for type resolution purposes). + * Generic types have their raw form added to the map, which has a pointer to the underlying generic. */ public static class TypeMap { @@ -1269,7 +1262,6 @@ public abstract class World implements Dump.INode { } return type; } else { - if (demotionSystemActive) { // System.out.println("Added since last demote " + key); addedSinceLastDemote.add(key); @@ -1295,7 +1287,8 @@ public abstract class World implements Dump.INode { if (!memoryProfiling) { return; } - while (rq.poll() != null) { + Reference r = null; + while ((r=rq.poll()) != null) { collectedTypes++; } } @@ -1311,11 +1304,17 @@ public abstract class World implements Dump.INode { WeakReference<ResolvedType> ref = (WeakReference<ResolvedType>) expendableMap.get(key); if (ref != null) { ret = ref.get(); +// if (ret==null) { +// expendableMap.remove(key); +// } } } else if (policy == USE_SOFT_REFS) { SoftReference<ResolvedType> ref = (SoftReference<ResolvedType>) expendableMap.get(key); if (ref != null) { ret = ref.get(); +// if (ret==null) { +// expendableMap.remove(key); +// } } // } else { // return (ResolvedType) expendableMap.get(key); |