From 6fcad31ac74d159a005fba2578fa836215cda3ea Mon Sep 17 00:00:00 2001 From: aclement Date: Sat, 7 Nov 2009 23:51:18 +0000 Subject: [PATCH] slowly merging in optimizations --- .../src/org/aspectj/weaver/ResolvedType.java | 50 ++----------------- .../weaver/patterns/DeclareAnnotation.java | 4 +- .../weaver/patterns/HasMemberTypePattern.java | 2 +- .../aspectj/weaver/patterns/IfPointcut.java | 2 +- 4 files changed, 7 insertions(+), 51 deletions(-) diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java index 0f919a380..fbf2f8464 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java @@ -211,8 +211,8 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl * @param wantGenerics is true if the caller would like all generics information, otherwise those methods are collapsed to their * erasure */ - public Iterator getMethods(boolean wantGenerics) { - return Iterators.mapOver(getHierarchy(wantGenerics, false), MethodGetterInstance); + public Iterator getMethods(boolean wantGenerics, boolean wantDeclaredParents) { + return Iterators.mapOver(getHierarchy(wantGenerics, wantDeclaredParents), MethodGetterInstance); } public Iterator getMethodsIncludingIntertypeDeclarations(boolean wantGenerics) { @@ -353,50 +353,6 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl } } - /** - * returns an iterator through all of the methods of this type, in order for checking from JVM spec 2ed 5.4.3.3. This means that - * the order is - *

- *

    - *
  • methods from current class
  • - *
  • recur into superclass, all the way up, not touching interfaces
  • - *
  • recur into all superinterfaces, in some unspecified order
  • - *
- *

- * We keep a hashSet of interfaces that we've visited so we don't spiral out into 2^n land. NOTE: Take a look at the javadoc on - * getMethodsWithoutIterator() to see if you are sensitive to a quirk in getMethods() - */ - public Iterator getMethods() { - final Iterators.Filter dupFilter = Iterators.dupFilter(); - Iterators.Getter ifaceGetter = new Iterators.Getter() { - public Iterator get(ResolvedType o) { - return dupFilter.filter(Iterators.array(o.getDeclaredInterfaces())); - } - }; - Iterators.Getter methodGetter = new Iterators.Getter() { - public Iterator get(ResolvedType o) { - return Iterators.array((o).getDeclaredMethods()); - } - }; - return Iterators.mapOver(Iterators.append(new Iterator() { - ResolvedType curr = ResolvedType.this; - - public boolean hasNext() { - return curr != null; - } - - public ResolvedType next() { - ResolvedType ret = curr; - curr = curr.getSuperclass(); - return ret; - } - - public void remove() { - throw new UnsupportedOperationException(); - } - }, Iterators.recur(this, ifaceGetter)), methodGetter); - } - /** * Return a list of methods, first those declared on this class, then those declared on the superclass (recurse) and then those * declared on the superinterfaces. This is expensive - use the getMethods() method if you can! @@ -1454,7 +1410,7 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl continue; } - for (Iterator iter = getMethods(); iter.hasNext();) { + for (Iterator iter = getMethods(true, true); iter.hasNext();) { ResolvedMember method = iter.next(); if (conflictingSignature(method, superMunger.getSignature())) { iter1.remove(); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareAnnotation.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareAnnotation.java index 3f8a01e69..261a01c4a 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareAnnotation.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareAnnotation.java @@ -326,7 +326,7 @@ public class DeclareAnnotation extends Declare { if (annotation != null) { return; } - for (Iterator iter = containingAspect.getMethods(); iter.hasNext();) { + for (Iterator iter = containingAspect.getMethods(true, true); iter.hasNext();) { ResolvedMember member = (ResolvedMember) iter.next(); if (member.getName().equals(annotationMethod)) { AnnotationAJ[] annos = member.getAnnotations(); @@ -388,7 +388,7 @@ public class DeclareAnnotation extends Declare { */ public ResolvedType getAnnotationType() { if (annotationType == null) { - for (Iterator iter = containingAspect.getMethods(); iter.hasNext();) { + for (Iterator iter = containingAspect.getMethods(true, true); iter.hasNext();) { ResolvedMember member = (ResolvedMember) iter.next(); if (member.getName().equals(annotationMethod)) { ResolvedType[] annoTypes = member.getAnnotationTypes(); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/HasMemberTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/HasMemberTypePattern.java index 8a202d71b..3cfc62c7b 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/HasMemberTypePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/HasMemberTypePattern.java @@ -75,7 +75,7 @@ public class HasMemberTypePattern extends TypePattern { private boolean hasMethod(ResolvedType type) { // TODO what about ITDs World world = type.getWorld(); - for (Iterator iter = type.getMethods(); iter.hasNext();) { + for (Iterator iter = type.getMethods(true, true); iter.hasNext();) { Member method = (Member) iter.next(); if (method.getName().startsWith(declareAtPrefix)) { continue; diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/IfPointcut.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/IfPointcut.java index f2cddbb90..c0e0f2b20 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/IfPointcut.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/IfPointcut.java @@ -345,7 +345,7 @@ public class IfPointcut extends Pointcut { ResolvedPointcutDefinition def = bindings.peekEnclosingDefinition(); if (def != null) { ResolvedType aspect = inAspect.getWorld().resolve(def.getDeclaringType()); - for (Iterator memberIter = aspect.getMethods(); memberIter.hasNext();) { + for (Iterator memberIter = aspect.getMethods(true, true); memberIter.hasNext();) { ResolvedMember method = (ResolvedMember) memberIter.next(); if (def.getName().equals(method.getName()) && def.getParameterTypes().length == method.getParameterTypes().length) { -- 2.39.5