summaryrefslogtreecommitdiffstats
path: root/weaver
diff options
context:
space:
mode:
authorjhugunin <jhugunin>2003-03-12 02:10:40 +0000
committerjhugunin <jhugunin>2003-03-12 02:10:40 +0000
commitad5377fcb2342ae792702a6641421620fceee244 (patch)
tree7705ecf82c4370c21ffe969887b7cadcd1bbf857 /weaver
parent0fb5f693794e571ab693813cbc80578b2bc7b470 (diff)
downloadaspectj-ad5377fcb2342ae792702a6641421620fceee244.tar.gz
aspectj-ad5377fcb2342ae792702a6641421620fceee244.zip
implemented fastMatch method along with some basic tests of
weave performance with and without it
Diffstat (limited to 'weaver')
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java63
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/AndPointcut.java4
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java4
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/CflowPointcut.java4
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/ConcreteCflowPointcut.java4
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/HandlerPointcut.java4
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/IfPointcut.java4
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/KindedPointcut.java15
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/NotPointcut.java12
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/OrPointcut.java12
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/PerCflow.java4
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/PerClause.java7
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/PerFromSuper.java4
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/PerObject.java4
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/PerSingleton.java4
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/Pointcut.java8
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java9
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java2
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java4
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java1
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/WithinPointcut.java41
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/WithincodePointcut.java4
-rw-r--r--weaver/testdata/aspectjtools.jarbin5196036 -> 0 bytes
-rw-r--r--weaver/testdata/dummyAspect.jarbin589 -> 591 bytes
-rw-r--r--weaver/testdata/megatrace.jarbin3558 -> 3562 bytes
-rw-r--r--weaver/testdata/megatrace0easy.jarbin0 -> 2902 bytes
-rw-r--r--weaver/testdata/megatrace0hard.jarbin0 -> 2802 bytes
-rw-r--r--weaver/testdata/megatraceNoweave.jarbin2712 -> 2717 bytes
-rw-r--r--weaver/testdata/tracing.jarbin2293 -> 2298 bytes
-rw-r--r--weaver/testsrc/org/aspectj/weaver/bcel/ZipTestCase.java16
30 files changed, 131 insertions, 103 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
index 11f3f3405..bb6515a40 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
@@ -13,34 +13,16 @@
package org.aspectj.weaver.bcel;
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-import java.util.zip.ZipOutputStream;
+import java.io.*;
+import java.util.*;
+import java.util.zip.*;
import org.apache.bcel.classfile.ClassParser;
import org.apache.bcel.classfile.JavaClass;
import org.aspectj.bridge.IMessage;
import org.aspectj.util.FileUtil;
-import org.aspectj.weaver.ConcreteTypeMunger;
-import org.aspectj.weaver.CrosscuttingMembersSet;
-import org.aspectj.weaver.IWeaver;
-import org.aspectj.weaver.ResolvedTypeX;
-import org.aspectj.weaver.TypeX;
+import org.aspectj.weaver.*;
+import org.aspectj.weaver.patterns.Pointcut;
public class BcelWeaver implements IWeaver {
private BcelWorld world;
@@ -327,8 +309,8 @@ public class BcelWeaver implements IWeaver {
}
JavaClass javaClass = classType.getJavaClass();
- List shadowMungers = fastMatch(shadowMungerList, javaClass);
- List typeMungers = fastMatch(classType.getResolvedTypeX().getInterTypeMungers(), javaClass);
+ List shadowMungers = fastMatch(shadowMungerList, classType.getResolvedTypeX());
+ List typeMungers = classType.getResolvedTypeX().getInterTypeMungers();
LazyClassGen clazz = null;
@@ -406,26 +388,17 @@ public class BcelWeaver implements IWeaver {
zipOutputStream.closeEntry();
}
- // ---- fast matching
-
-// boolean fastMatch(JavaClass jc) {
-// ConstantPool pool = jc.getConstantPool();
-// for (int i=0, len=pool.getLength(); i < len; i++) {
-// Constant c = pool.getConstant(i);
-// if (c instanceof ConstantNameAndType) {
-// ConstantNameAndType nt = (ConstantNameAndType)c;
-// if (nt.getName(pool).equals("toShortString")) {
-// //System.out.println("found in " + jc);
-// return true;
-// }
-// }
-// }
-// return false;
-// }
-
- //XXX need to implement a real fast-match here
- private List fastMatch(List list, JavaClass javaClass) {
+ private List fastMatch(List list, ResolvedTypeX type) {
if (list == null) return Collections.EMPTY_LIST;
- return list;
+
+ List result = new ArrayList();
+ Iterator iter = list.iterator();
+ while (iter.hasNext()) {
+ ShadowMunger munger = (ShadowMunger)iter.next();
+ if (munger.getPointcut().fastMatch(type).maybeTrue()) {
+ result.add(munger);
+ }
+ }
+ return result;
}
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/AndPointcut.java b/weaver/src/org/aspectj/weaver/patterns/AndPointcut.java
index f0e270d9b..352023def 100644
--- a/weaver/src/org/aspectj/weaver/patterns/AndPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/AndPointcut.java
@@ -34,6 +34,10 @@ public class AndPointcut extends Pointcut {
setLocation(left.getSourceContext(), left.getStart(), right.getEnd());
}
+ public FuzzyBoolean fastMatch(ResolvedTypeX type) {
+ return left.fastMatch(type).and(right.fastMatch(type));
+ }
+
public FuzzyBoolean match(Shadow shadow) {
return left.match(shadow).and(right.match(shadow));
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java b/weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java
index 3cfff4a68..ce79c5608 100644
--- a/weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java
@@ -40,6 +40,10 @@ public class ArgsPointcut extends NameBindingPointcut {
public ArgsPointcut(TypePatternList arguments) {
this.arguments = arguments;
}
+
+ public FuzzyBoolean fastMatch(ResolvedTypeX type) {
+ return FuzzyBoolean.MAYBE;
+ }
public FuzzyBoolean match(Shadow shadow) {
FuzzyBoolean ret =
diff --git a/weaver/src/org/aspectj/weaver/patterns/CflowPointcut.java b/weaver/src/org/aspectj/weaver/patterns/CflowPointcut.java
index 5cc3eb4df..68d9a4e88 100644
--- a/weaver/src/org/aspectj/weaver/patterns/CflowPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/CflowPointcut.java
@@ -59,6 +59,10 @@ public class CflowPointcut extends Pointcut {
this.freeVars = freeVars;
}
+ public FuzzyBoolean fastMatch(ResolvedTypeX type) {
+ return FuzzyBoolean.MAYBE;
+ }
+
public FuzzyBoolean match(Shadow shadow) {
//??? this is not maximally efficient
return FuzzyBoolean.MAYBE;
diff --git a/weaver/src/org/aspectj/weaver/patterns/ConcreteCflowPointcut.java b/weaver/src/org/aspectj/weaver/patterns/ConcreteCflowPointcut.java
index e20a9a12a..3354dbbbf 100644
--- a/weaver/src/org/aspectj/weaver/patterns/ConcreteCflowPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/ConcreteCflowPointcut.java
@@ -40,6 +40,10 @@ public class ConcreteCflowPointcut extends Pointcut {
this.slots = slots;
}
+ public FuzzyBoolean fastMatch(ResolvedTypeX type) {
+ return FuzzyBoolean.MAYBE;
+ }
+
public FuzzyBoolean match(Shadow shadow) {
//??? this is not maximally efficient
return FuzzyBoolean.MAYBE;
diff --git a/weaver/src/org/aspectj/weaver/patterns/HandlerPointcut.java b/weaver/src/org/aspectj/weaver/patterns/HandlerPointcut.java
index 243205b7e..258c8ac80 100644
--- a/weaver/src/org/aspectj/weaver/patterns/HandlerPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/HandlerPointcut.java
@@ -38,6 +38,10 @@ public class HandlerPointcut extends Pointcut {
this.exceptionType = exceptionType;
}
+ public FuzzyBoolean fastMatch(ResolvedTypeX type) {
+ //??? should be able to do better by finding all referenced types in type
+ return FuzzyBoolean.MAYBE;
+ }
public FuzzyBoolean match(Shadow shadow) {
if (shadow.getKind() != Shadow.ExceptionHandler) return FuzzyBoolean.NO;
diff --git a/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java b/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java
index 267e5e00c..9fd8a73ec 100644
--- a/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java
@@ -49,6 +49,10 @@ public class IfPointcut extends Pointcut {
this.testMethod = testMethod;
this.extraParameterFlags = extraParameterFlags;
}
+
+ public FuzzyBoolean fastMatch(ResolvedTypeX type) {
+ return FuzzyBoolean.MAYBE;
+ }
public FuzzyBoolean match(Shadow shadow) {
//??? this is not maximally efficient
diff --git a/weaver/src/org/aspectj/weaver/patterns/KindedPointcut.java b/weaver/src/org/aspectj/weaver/patterns/KindedPointcut.java
index 1204c97a4..6fd204257 100644
--- a/weaver/src/org/aspectj/weaver/patterns/KindedPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/KindedPointcut.java
@@ -13,16 +13,10 @@
package org.aspectj.weaver.patterns;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
+import java.io.*;
-import org.apache.bcel.classfile.JavaClass;
import org.aspectj.util.FuzzyBoolean;
-import org.aspectj.weaver.ISourceContext;
-import org.aspectj.weaver.IntMap;
-import org.aspectj.weaver.ResolvedTypeX;
-import org.aspectj.weaver.Shadow;
+import org.aspectj.weaver.*;
import org.aspectj.weaver.ast.Literal;
import org.aspectj.weaver.ast.Test;
@@ -37,8 +31,9 @@ public class KindedPointcut extends Pointcut {
this.signature = signature;
}
- public boolean fastMatch(JavaClass jc) { return true; }
-
+ public FuzzyBoolean fastMatch(ResolvedTypeX type) {
+ return FuzzyBoolean.MAYBE;
+ }
public FuzzyBoolean match(Shadow shadow) {
if (shadow.getKind() != kind) return FuzzyBoolean.NO;
diff --git a/weaver/src/org/aspectj/weaver/patterns/NotPointcut.java b/weaver/src/org/aspectj/weaver/patterns/NotPointcut.java
index 56ade7763..d10eea34f 100644
--- a/weaver/src/org/aspectj/weaver/patterns/NotPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/NotPointcut.java
@@ -31,20 +31,16 @@ public class NotPointcut extends Pointcut {
this.body = left;
}
- /**
- * Constructor NotPointcut.
- * @param pointcut
- * @param startPos
- */
public NotPointcut(Pointcut pointcut, int startPos) {
this(pointcut);
setLocation(pointcut.getSourceContext(), startPos, pointcut.getEnd());
}
- /**
- * @see org.aspectj.weaver.patterns.Pointcut#match(BcelShadow)
- */
+ public FuzzyBoolean fastMatch(ResolvedTypeX type) {
+ return body.fastMatch(type).not();
+ }
+
public FuzzyBoolean match(Shadow shadow) {
return body.match(shadow).not();
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/OrPointcut.java b/weaver/src/org/aspectj/weaver/patterns/OrPointcut.java
index a66d0e1e1..631ad6666 100644
--- a/weaver/src/org/aspectj/weaver/patterns/OrPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/OrPointcut.java
@@ -26,9 +26,7 @@ import org.aspectj.weaver.ast.Test;
public class OrPointcut extends Pointcut {
private Pointcut left, right;
- /**
- * Constructor for AndPointcut.
- */
+
public OrPointcut(Pointcut left, Pointcut right) {
super();
this.left = left;
@@ -36,9 +34,11 @@ public class OrPointcut extends Pointcut {
setLocation(left.getSourceContext(), left.getStart(), right.getEnd());
}
- /**
- * @see org.aspectj.weaver.patterns.Pointcut#match(BcelShadow)
- */
+
+ public FuzzyBoolean fastMatch(ResolvedTypeX type) {
+ return left.fastMatch(type).or(right.fastMatch(type));
+ }
+
public FuzzyBoolean match(Shadow shadow) {
return left.match(shadow).or(right.match(shadow));
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/PerCflow.java b/weaver/src/org/aspectj/weaver/patterns/PerCflow.java
index 9af28b7ee..fe815e3ba 100644
--- a/weaver/src/org/aspectj/weaver/patterns/PerCflow.java
+++ b/weaver/src/org/aspectj/weaver/patterns/PerCflow.java
@@ -47,6 +47,10 @@ public class PerCflow extends PerClause {
// -----
+ public FuzzyBoolean fastMatch(ResolvedTypeX type) {
+ return FuzzyBoolean.MAYBE;
+ }
+
public FuzzyBoolean match(Shadow shadow) {
return FuzzyBoolean.YES;
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/PerClause.java b/weaver/src/org/aspectj/weaver/patterns/PerClause.java
index 7764b15cb..b28e8fc24 100644
--- a/weaver/src/org/aspectj/weaver/patterns/PerClause.java
+++ b/weaver/src/org/aspectj/weaver/patterns/PerClause.java
@@ -17,10 +17,7 @@ import java.io.DataInputStream;
import java.io.IOException;
import org.aspectj.util.TypeSafeEnum;
-import org.aspectj.weaver.BCException;
-import org.aspectj.weaver.ISourceContext;
-import org.aspectj.weaver.IntMap;
-import org.aspectj.weaver.ResolvedTypeX;
+import org.aspectj.weaver.*;
public abstract class PerClause extends Pointcut {
protected ResolvedTypeX inAspect;
@@ -41,10 +38,8 @@ public abstract class PerClause extends Pointcut {
public abstract PerClause concretize(ResolvedTypeX inAspect);
-
public abstract PerClause.Kind getKind();
-
public static class Kind extends TypeSafeEnum {
public Kind(String name, int key) { super(name, key); }
diff --git a/weaver/src/org/aspectj/weaver/patterns/PerFromSuper.java b/weaver/src/org/aspectj/weaver/patterns/PerFromSuper.java
index 0977d7c7c..4976d2f7f 100644
--- a/weaver/src/org/aspectj/weaver/patterns/PerFromSuper.java
+++ b/weaver/src/org/aspectj/weaver/patterns/PerFromSuper.java
@@ -31,6 +31,10 @@ public class PerFromSuper extends PerClause {
this.kind = kind;
}
+ public FuzzyBoolean fastMatch(ResolvedTypeX type) {
+ throw new RuntimeException("unimplemented");
+ }
+
public FuzzyBoolean match(Shadow shadow) {
throw new RuntimeException("unimplemented");
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/PerObject.java b/weaver/src/org/aspectj/weaver/patterns/PerObject.java
index d49536abe..de70b35e2 100644
--- a/weaver/src/org/aspectj/weaver/patterns/PerObject.java
+++ b/weaver/src/org/aspectj/weaver/patterns/PerObject.java
@@ -40,6 +40,10 @@ public class PerObject extends PerClause {
}
// -----
+ public FuzzyBoolean fastMatch(ResolvedTypeX type) {
+ return FuzzyBoolean.MAYBE;
+ }
+
public FuzzyBoolean match(Shadow shadow) {
//System.err.println("matches " + this + " ? " + shadow + ", " + shadow.hasTarget());
diff --git a/weaver/src/org/aspectj/weaver/patterns/PerSingleton.java b/weaver/src/org/aspectj/weaver/patterns/PerSingleton.java
index 553bc5a94..6399b6430 100644
--- a/weaver/src/org/aspectj/weaver/patterns/PerSingleton.java
+++ b/weaver/src/org/aspectj/weaver/patterns/PerSingleton.java
@@ -30,6 +30,10 @@ public class PerSingleton extends PerClause {
public PerSingleton() {
}
+ public FuzzyBoolean fastMatch(ResolvedTypeX type) {
+ return FuzzyBoolean.YES;
+ }
+
public FuzzyBoolean match(Shadow shadow) {
return FuzzyBoolean.YES;
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/Pointcut.java b/weaver/src/org/aspectj/weaver/patterns/Pointcut.java
index 4d1696ae6..3cd0c9cf6 100644
--- a/weaver/src/org/aspectj/weaver/patterns/Pointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/Pointcut.java
@@ -61,9 +61,9 @@ public abstract class Pointcut extends PatternNode {
/**
- * Could I match any shadows in this JavaClass
+ * Could I match any shadows in the code defined within this type?
*/
- public boolean fastMatch(JavaClass jc) { return true; }
+ public abstract FuzzyBoolean fastMatch(ResolvedTypeX type);
/**
* Do I really match this shadow?
@@ -195,6 +195,10 @@ public abstract class Pointcut extends PatternNode {
return Literal.FALSE; // can only get here if an earlier error occurred
}
+ public FuzzyBoolean fastMatch(ResolvedTypeX type) {
+ return FuzzyBoolean.NO;
+ }
+
public FuzzyBoolean match(Shadow shadow) {
return FuzzyBoolean.NO;
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java b/weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java
index 1a12423b2..2d3291792 100644
--- a/weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java
@@ -55,10 +55,11 @@ public class ReferencePointcut extends Pointcut {
this.arguments = arguments;
}
- /**
- * Could I match any shadows in this JavaClass
- */
- public boolean fastMatch(JavaClass jc) { return true; }
+
+ //??? do either of these match methods make any sense???
+ public FuzzyBoolean fastMatch(ResolvedTypeX type) {
+ return FuzzyBoolean.MAYBE;
+ }
/**
* Do I really match this shadow?
diff --git a/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java b/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java
index 28ffb33dc..d6db93f10 100644
--- a/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java
@@ -83,7 +83,7 @@ public class SignaturePattern extends PatternNode {
public boolean matches(Member member, World world) {
//XXX performance gains would come from matching on name before resolving
- // to fail fast
+ // to fail fast
ResolvedMember sig = member.resolve(world);
if (sig == null) {
//XXX
diff --git a/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java b/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java
index 4b4e80766..4fd791031 100644
--- a/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java
@@ -50,6 +50,10 @@ public class ThisOrTargetPointcut extends NameBindingPointcut {
this.type = type;
}
+ public FuzzyBoolean fastMatch(ResolvedTypeX type) {
+ return FuzzyBoolean.MAYBE;
+ }
+
private boolean couldMatch(Shadow shadow) {
return isThis ? shadow.hasThis() : shadow.hasTarget();
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java
index 45f132875..3b1da45ed 100644
--- a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java
@@ -39,7 +39,6 @@ public class WildTypePattern extends TypePattern {
WildTypePattern(NamePattern[] namePatterns, boolean includeSubtypes, int dim) {
super(includeSubtypes);
this.namePatterns = namePatterns;
- this.ellipsisCount = ellipsisCount;
this.dim = dim;
ellipsisCount = 0;
for (int i=0; i<namePatterns.length; i++) {
diff --git a/weaver/src/org/aspectj/weaver/patterns/WithinPointcut.java b/weaver/src/org/aspectj/weaver/patterns/WithinPointcut.java
index c3ddb5f19..f2f8addc6 100644
--- a/weaver/src/org/aspectj/weaver/patterns/WithinPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/WithinPointcut.java
@@ -27,31 +27,34 @@ import org.aspectj.weaver.ast.Literal;
import org.aspectj.weaver.ast.Test;
public class WithinPointcut extends Pointcut {
- TypePattern type;
+ TypePattern typePattern;
public WithinPointcut(TypePattern type) {
- this.type = type;
+ this.typePattern = type;
}
-
- public FuzzyBoolean match(Shadow shadow) {
- ResolvedTypeX enclosingType = shadow.getIWorld().resolve(shadow.getEnclosingType());
- //System.err.println("enclosingType: " + enclosingType);
-// if (shadow.getKind() == Shadow.FieldSet) {
-// System.err.println("within?" + type + " matches " + enclosingType + " on " + shadow);
-// }
-
- while (enclosingType != null) {
- if (type.matchesStatically(enclosingType)) {
+
+ private FuzzyBoolean isWithinType(ResolvedTypeX type) {
+ while (type != null) {
+ if (typePattern.matchesStatically(type)) {
return FuzzyBoolean.YES;
}
- enclosingType = enclosingType.getDeclaringType();
+ type = type.getDeclaringType();
}
return FuzzyBoolean.NO;
}
+
+ public FuzzyBoolean fastMatch(ResolvedTypeX type) {
+ return isWithinType(type);
+ }
+
+ public FuzzyBoolean match(Shadow shadow) {
+ ResolvedTypeX enclosingType = shadow.getIWorld().resolve(shadow.getEnclosingType());
+ return isWithinType(enclosingType);
+ }
public void write(DataOutputStream s) throws IOException {
s.writeByte(Pointcut.WITHIN);
- type.write(s);
+ typePattern.write(s);
writeLocation(s);
}
public static Pointcut read(DataInputStream s, ISourceContext context) throws IOException {
@@ -62,26 +65,26 @@ public class WithinPointcut extends Pointcut {
}
public void resolveBindings(IScope scope, Bindings bindings) {
- type = type.resolveBindings(scope, bindings, false, false);
+ typePattern = typePattern.resolveBindings(scope, bindings, false, false);
}
public void postRead(ResolvedTypeX enclosingType) {
- type.postRead(enclosingType);
+ typePattern.postRead(enclosingType);
}
public boolean equals(Object other) {
if (!(other instanceof WithinPointcut)) return false;
WithinPointcut o = (WithinPointcut)other;
- return o.type.equals(this.type);
+ return o.typePattern.equals(this.typePattern);
}
public int hashCode() {
int result = 43;
- result = 37*result + type.hashCode();
+ result = 37*result + typePattern.hashCode();
return result;
}
public String toString() {
- return "within(" + type + ")";
+ return "within(" + typePattern + ")";
}
public Test findResidue(Shadow shadow, ExposedState state) {
diff --git a/weaver/src/org/aspectj/weaver/patterns/WithincodePointcut.java b/weaver/src/org/aspectj/weaver/patterns/WithincodePointcut.java
index 2b01f961a..d673c8ecb 100644
--- a/weaver/src/org/aspectj/weaver/patterns/WithincodePointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/WithincodePointcut.java
@@ -32,6 +32,10 @@ public class WithincodePointcut extends Pointcut {
this.signature = signature;
}
+ public FuzzyBoolean fastMatch(ResolvedTypeX type) {
+ return FuzzyBoolean.MAYBE;
+ }
+
public FuzzyBoolean match(Shadow shadow) {
//This will not match code in local or anonymous classes as if
//they were withincode of the outer signature
diff --git a/weaver/testdata/aspectjtools.jar b/weaver/testdata/aspectjtools.jar
deleted file mode 100644
index b75dfa0ee..000000000
--- a/weaver/testdata/aspectjtools.jar
+++ /dev/null
Binary files differ
diff --git a/weaver/testdata/dummyAspect.jar b/weaver/testdata/dummyAspect.jar
index 54b76f013..fd37338f4 100644
--- a/weaver/testdata/dummyAspect.jar
+++ b/weaver/testdata/dummyAspect.jar
Binary files differ
diff --git a/weaver/testdata/megatrace.jar b/weaver/testdata/megatrace.jar
index 8c0843c28..13fde4cc1 100644
--- a/weaver/testdata/megatrace.jar
+++ b/weaver/testdata/megatrace.jar
Binary files differ
diff --git a/weaver/testdata/megatrace0easy.jar b/weaver/testdata/megatrace0easy.jar
new file mode 100644
index 000000000..47549443c
--- /dev/null
+++ b/weaver/testdata/megatrace0easy.jar
Binary files differ
diff --git a/weaver/testdata/megatrace0hard.jar b/weaver/testdata/megatrace0hard.jar
new file mode 100644
index 000000000..70f820036
--- /dev/null
+++ b/weaver/testdata/megatrace0hard.jar
Binary files differ
diff --git a/weaver/testdata/megatraceNoweave.jar b/weaver/testdata/megatraceNoweave.jar
index dba8efbff..cb2a819f2 100644
--- a/weaver/testdata/megatraceNoweave.jar
+++ b/weaver/testdata/megatraceNoweave.jar
Binary files differ
diff --git a/weaver/testdata/tracing.jar b/weaver/testdata/tracing.jar
index 18bf1b759..6e178f867 100644
--- a/weaver/testdata/tracing.jar
+++ b/weaver/testdata/tracing.jar
Binary files differ
diff --git a/weaver/testsrc/org/aspectj/weaver/bcel/ZipTestCase.java b/weaver/testsrc/org/aspectj/weaver/bcel/ZipTestCase.java
index c39dad22a..ecc961a75 100644
--- a/weaver/testsrc/org/aspectj/weaver/bcel/ZipTestCase.java
+++ b/weaver/testsrc/org/aspectj/weaver/bcel/ZipTestCase.java
@@ -51,6 +51,7 @@ public class ZipTestCase extends TestCase {
weaver.addLibraryJarFile(new File(aspectjar));
}
}
+ weaver.addLibraryJarFile(new File("testdata/Regex.jar")); //???
Collection woven = weaver.weave(outFile);
@@ -76,11 +77,24 @@ public class ZipTestCase extends TestCase {
zipTest("testdata/Regex.jar", "testdata/megatraceNoweave.jar", true);
}
- // this is something we test every now and again.
+
public void testBig() throws IOException {
System.out.println("could take 4 seconds...");
zipTest("../lib/bcel/bcel.jar", null);
}
+
+
+ public void testBigWithEasyNoTrace() throws IOException {
+ System.out.println("could take 4 seconds...");
+ zipTest("../lib/bcel/bcel.jar", "testdata/megatrace0easy.jar");
+ }
+
+ // this is something we test every now and again.
+ public void xtestBigWithHardNoTrace() throws IOException {
+ System.out.println("could take 24 seconds...");
+ zipTest("../lib/bcel/bcel.jar", "testdata/megatrace0hard.jar");
+ }
+
public void xtestBigWithAspects() throws IOException {
System.out.println("could take 40 seconds...");