summaryrefslogtreecommitdiffstats
path: root/org.aspectj.matcher
diff options
context:
space:
mode:
authoraclement <aclement>2011-04-27 20:54:05 +0000
committeraclement <aclement>2011-04-27 20:54:05 +0000
commitf8ff09094b862b63ec44f8215f8e70337b93cb57 (patch)
treed07e0119b193a87ff4891bd89453e11afe40815b /org.aspectj.matcher
parentd1ad6dc8e8291d7f9c7277cad206a3e57eb5cd59 (diff)
downloadaspectj-f8ff09094b862b63ec44f8215f8e70337b93cb57.tar.gz
aspectj-f8ff09094b862b63ec44f8215f8e70337b93cb57.zip
344005: fix. Tests are in here but unfinished.
Diffstat (limited to 'org.aspectj.matcher')
-rw-r--r--org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java33
-rw-r--r--org.aspectj.matcher/src/org/aspectj/weaver/World.java1
2 files changed, 31 insertions, 3 deletions
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java b/org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java
index 28718d474..cef0defce 100644
--- a/org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java
+++ b/org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java
@@ -15,8 +15,10 @@ package org.aspectj.weaver;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.aspectj.bridge.ISourceLocation;
import org.aspectj.weaver.patterns.Declare;
@@ -36,7 +38,7 @@ public class ReferenceType extends ResolvedType {
* For generic types, this list holds references to all the derived raw and parameterized versions. We need this so that if the
* generic delegate is swapped during incremental compilation, the delegate of the derivatives is swapped also.
*/
- private final List<ReferenceType> derivativeTypes = new ArrayList<ReferenceType>();
+ private final Set<ReferenceType> derivativeTypes = new HashSet<ReferenceType>();
/**
* For parameterized types (or the raw type) - this field points to the actual reference type from which they are derived.
@@ -111,7 +113,7 @@ public class ReferenceType extends ResolvedType {
// this.delegate = genericReferenceType.getDelegate();
// genericReferenceType.addDependentType(this);
// }
- private synchronized void addDependentType(ReferenceType dependent) {
+ synchronized void addDependentType(ReferenceType dependent) {
this.derivativeTypes.add(dependent);
}
@@ -622,11 +624,23 @@ public class ReferenceType extends ResolvedType {
return interfaces;
}
ResolvedType[] delegateInterfaces = getDelegate().getDeclaredInterfaces();
- if (newInterfaces != null) {
+ if (isRawType()) {
+ if (newInterfaces!=null) {
+ throw new IllegalStateException("The raw type should never be accumulating new interfaces, they should be on the generic type. Type is "+this.getName());
+ }
+ ResolvedType[] newInterfacesFromGenericType = genericType.newInterfaces;
+ if (newInterfacesFromGenericType!=null) {
+ ResolvedType[] extraInterfaces = new ResolvedType[delegateInterfaces.length + newInterfacesFromGenericType.length];
+ System.arraycopy(delegateInterfaces, 0, extraInterfaces, 0, delegateInterfaces.length);
+ System.arraycopy(newInterfacesFromGenericType, 0, extraInterfaces, delegateInterfaces.length, newInterfacesFromGenericType.length);
+ delegateInterfaces = extraInterfaces;
+ }
+ } else if (newInterfaces != null) {
// OPTIMIZE does this part of the method trigger often?
ResolvedType[] extraInterfaces = new ResolvedType[delegateInterfaces.length + newInterfaces.length];
System.arraycopy(delegateInterfaces, 0, extraInterfaces, 0, delegateInterfaces.length);
System.arraycopy(newInterfaces, 0, extraInterfaces, delegateInterfaces.length, newInterfaces.length);
+
delegateInterfaces = extraInterfaces;
}
if (isParameterizedType()) {
@@ -951,6 +965,7 @@ public class ReferenceType extends ResolvedType {
parameterizedPointcuts = null;
superclassReference = new WeakReference<ResolvedType>(null);
}
+
public int getEndPos() {
return endPos;
@@ -985,6 +1000,13 @@ public class ReferenceType extends ResolvedType {
typeKind = TypeKind.RAW;
signatureErasure = signature;
}
+ if (typeKind==TypeKind.RAW){
+ genericType.addDependentType(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();
+ }
}
public void demoteToSimpleType() {
@@ -1070,6 +1092,11 @@ public class ReferenceType extends ResolvedType {
newNewInterfaces[0] = newParent;
newInterfaces = newNewInterfaces;
}
+ if (this.isGenericType()) {
+ for (ReferenceType derivativeType:derivativeTypes) {
+ derivativeType.parameterizedInterfaces.clear();
+ }
+ }
parameterizedInterfaces.clear();
}
}
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/World.java b/org.aspectj.matcher/src/org/aspectj/weaver/World.java
index 43a63b10d..5a57c5ef3 100644
--- a/org.aspectj.matcher/src/org/aspectj/weaver/World.java
+++ b/org.aspectj.matcher/src/org/aspectj/weaver/World.java
@@ -529,6 +529,7 @@ public abstract class World implements Dump.INode {
if (genericType != null) {
genericType.world = this;
+ ((ReferenceType)genericType).addDependentType((ReferenceType)rawType);
return genericType;
} else {
// Fault in the generic that underpins the raw type ;)