summaryrefslogtreecommitdiffstats
path: root/org.aspectj.matcher
diff options
context:
space:
mode:
authoraclement <aclement>2009-11-13 18:23:55 +0000
committeraclement <aclement>2009-11-13 18:23:55 +0000
commitbbe9ce4a1929279ddff6cda6394863a311beb231 (patch)
treeb9718d44d81497ab592f0f85e51ccc1ae0b20b5d /org.aspectj.matcher
parent1524023405b6b1e596986fa44a6db48e5d401acc (diff)
downloadaspectj-bbe9ce4a1929279ddff6cda6394863a311beb231.tar.gz
aspectj-bbe9ce4a1929279ddff6cda6394863a311beb231.zip
weakref cache of resolved interfaces and supertype
Diffstat (limited to 'org.aspectj.matcher')
-rw-r--r--org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java38
1 files changed, 33 insertions, 5 deletions
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java b/org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java
index e8e7e0b4c..5155c495b 100644
--- a/org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java
+++ b/org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java
@@ -12,6 +12,7 @@
* ******************************************************************/
package org.aspectj.weaver;
+import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
@@ -570,9 +571,7 @@ public class ReferenceType extends ResolvedType {
@Override
public boolean isExposedToWeaver() {
- return (delegate == null) || delegate.isExposedToWeaver(); // ??? where
- // does this
- // belong
+ return (delegate == null) || delegate.isExposedToWeaver();
}
@Override
@@ -649,9 +648,23 @@ public class ReferenceType extends ResolvedType {
}
return parameterizedInterfaces;
}
+ if (delegate.isCacheable()) {
+ parameterizedInterfaces = delegateInterfaces;
+ }
+
return delegateInterfaces;
}
+ private String toString(ResolvedType[] delegateInterfaces) {
+ StringBuffer sb = new StringBuffer();
+ if (delegateInterfaces != null) {
+ for (ResolvedType rt : delegateInterfaces) {
+ sb.append(rt).append(" ");
+ }
+ }
+ return sb.toString();
+ }
+
/**
* Locates the named type variable in the list of those on this generic type and returns the type parameter from the second list
* supplied. Returns null if it can't be found
@@ -856,15 +869,23 @@ public class ReferenceType extends ResolvedType {
return delegate.getModifiers();
}
+ WeakReference<ResolvedType> superclassReference = new WeakReference<ResolvedType>(null);
+
@Override
public ResolvedType getSuperclass() {
+ ResolvedType ret = null;// superclassReference.get();
+ if (ret != null) {
+ return ret;
+ }
if (newSuperclass != null) {
if (this.isParameterizedType() && newSuperclass.isParameterizedType()) {
return newSuperclass.parameterize(getMemberParameterizationMap()).resolve(getWorld());
}
+ if (delegate.isCacheable()) {
+ superclassReference = new WeakReference<ResolvedType>(ret);
+ }
return newSuperclass;
}
- ResolvedType ret = null;
try {
world.setTypeVariableLookupScope(this);
ret = delegate.getSuperclass();
@@ -874,6 +895,9 @@ public class ReferenceType extends ResolvedType {
if (this.isParameterizedType() && ret.isParameterizedType()) {
ret = ret.parameterize(getMemberParameterizationMap()).resolve(getWorld());
}
+ if (delegate.isCacheable()) {
+ superclassReference = new WeakReference<ResolvedType>(ret);
+ }
return ret;
}
@@ -911,6 +935,7 @@ public class ReferenceType extends ResolvedType {
parameterizedInterfaces = null;
parameterizedMethods = null;
parameterizedPointcuts = null;
+ superclassReference = new WeakReference<ResolvedType>(null);
}
public int getEndPos() {
@@ -1000,12 +1025,15 @@ public class ReferenceType extends ResolvedType {
annotationTypes = null;
newSuperclass = null;
newInterfaces = null;
+ parameterizedInterfaces = null;
+ superclassReference = new WeakReference<ResolvedType>(null);
}
@Override
public void addParent(ResolvedType newParent) {
if (newParent.isClass()) {
newSuperclass = newParent;
+ superclassReference = new WeakReference<ResolvedType>(null);
} else {
if (newInterfaces == null) {
newInterfaces = new ResolvedType[1];
@@ -1023,8 +1051,8 @@ public class ReferenceType extends ResolvedType {
System.arraycopy(newInterfaces, 0, newNewInterfaces, 1, newInterfaces.length);
newNewInterfaces[0] = newParent;
newInterfaces = newNewInterfaces;
- parameterizedInterfaces = null;// invalidate cached info
}
+ parameterizedInterfaces = null;// invalidate cached info
}
}
} \ No newline at end of file