aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoracolyer <acolyer>2006-05-16 15:43:08 +0000
committeracolyer <acolyer>2006-05-16 15:43:08 +0000
commitb166a7e6163889eb951f82655f0f49bfc26a49f0 (patch)
tree2801163d063b198536b71b39d9c0a340d9f753fc
parentfc7db25dad5d302221669c7cfdb4890f061d2e9e (diff)
downloadaspectj-b166a7e6163889eb951f82655f0f49bfc26a49f0.tar.gz
aspectj-b166a7e6163889eb951f82655f0f49bfc26a49f0.zip
tests and fix for pr130722, 138219
-rw-r--r--tests/bugs152/pr130722/test/PointcutConsumer.aj15
-rw-r--r--tests/bugs152/pr130722/test/Test.java11
-rw-r--r--tests/bugs152/pr130722/test1/PointcutProvider.aj9
-rw-r--r--tests/bugs152/pr138219/PerThisWithReference.aj25
-rw-r--r--tests/bugs152/pr138219/RegularPCWithReference.aj8
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/GenericITDsDesign.java2
-rw-r--r--tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java3
-rw-r--r--tests/src/org/aspectj/systemtest/ajc152/ajc152.xml12
-rw-r--r--weaver/src/org/aspectj/weaver/CrosscuttingMembers.java23
-rw-r--r--weaver/src/org/aspectj/weaver/CrosscuttingMembersSet.java14
-rw-r--r--weaver/src/org/aspectj/weaver/ResolvedType.java4
-rw-r--r--weaver/testsrc/org/aspectj/weaver/bcel/NonstaticWeaveTestCase.java4
-rw-r--r--weaver/testsrc/org/aspectj/weaver/bcel/PointcutResidueTestCase.java2
-rw-r--r--weaver/testsrc/org/aspectj/weaver/bcel/WeaveOrderTestCase.java4
14 files changed, 109 insertions, 27 deletions
diff --git a/tests/bugs152/pr130722/test/PointcutConsumer.aj b/tests/bugs152/pr130722/test/PointcutConsumer.aj
new file mode 100644
index 000000000..609cb91b4
--- /dev/null
+++ b/tests/bugs152/pr130722/test/PointcutConsumer.aj
@@ -0,0 +1,15 @@
+package test;
+
+import test1.PointcutProvider;
+
+public aspect PointcutConsumer percflow(flow()) {
+
+ // compiler issues the following line with
+ // can not find pointcut test on test.PointcutConsumer
+ pointcut mytest(): PointcutProvider.test();
+
+ // this also does not work with the same error message
+ pointcut mytest2(): test1.PointcutProvider.test();
+
+ pointcut flow(): mytest() || mytest2();
+} \ No newline at end of file
diff --git a/tests/bugs152/pr130722/test/Test.java b/tests/bugs152/pr130722/test/Test.java
new file mode 100644
index 000000000..35f80ec40
--- /dev/null
+++ b/tests/bugs152/pr130722/test/Test.java
@@ -0,0 +1,11 @@
+package test;
+
+
+public class Test {
+
+ public void foo() {
+
+ }
+}
+
+
diff --git a/tests/bugs152/pr130722/test1/PointcutProvider.aj b/tests/bugs152/pr130722/test1/PointcutProvider.aj
new file mode 100644
index 000000000..7bae7adce
--- /dev/null
+++ b/tests/bugs152/pr130722/test1/PointcutProvider.aj
@@ -0,0 +1,9 @@
+package test1;
+
+import test.Test;
+public aspect PointcutProvider {
+
+ public pointcut test(): execution(* Test.*(..));
+}
+
+
diff --git a/tests/bugs152/pr138219/PerThisWithReference.aj b/tests/bugs152/pr138219/PerThisWithReference.aj
index c53466dfe..e7c448fa0 100644
--- a/tests/bugs152/pr138219/PerThisWithReference.aj
+++ b/tests/bugs152/pr138219/PerThisWithReference.aj
@@ -1,7 +1,30 @@
public aspect PerThisWithReference perthis(mypc()) {
+ private static int id = 0;
+
+ public PerThisWithReference() {
+ id++;
+ }
+
+ public String toString() {
+ return "PerThisWithReference:" + id;
+ }
- pointcut mypc() : SomeOtherType.pc();
+ public static void main(String[] args) {
+ new C().foo();
+ new C().foo();
+ }
+ pointcut mypc() : SomeOtherType.pc() && within(C);
+
+ before() : mypc() {
+ System.out.println("before " + this);
+ }
+
+}
+
+class C {
+
+ public void foo() {}
} \ No newline at end of file
diff --git a/tests/bugs152/pr138219/RegularPCWithReference.aj b/tests/bugs152/pr138219/RegularPCWithReference.aj
new file mode 100644
index 000000000..ca7ab0939
--- /dev/null
+++ b/tests/bugs152/pr138219/RegularPCWithReference.aj
@@ -0,0 +1,8 @@
+public aspect RegularPCWithReference {
+
+ pointcut refersToMypc() : mypc();
+
+ pointcut mypc() : SomeOtherType.pc();
+
+
+} \ No newline at end of file
diff --git a/tests/src/org/aspectj/systemtest/ajc150/GenericITDsDesign.java b/tests/src/org/aspectj/systemtest/ajc150/GenericITDsDesign.java
index 2a1bb9ac5..e389df79c 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/GenericITDsDesign.java
+++ b/tests/src/org/aspectj/systemtest/ajc150/GenericITDsDesign.java
@@ -81,7 +81,7 @@ public class GenericITDsDesign extends XMLBasedAjcTestCase {
System.getProperty("java.class.path"));
recentWorld = new BcelWorld(cp.toString());
ReferenceType resolvedType = (ReferenceType)recentWorld.resolve(classname);
- CrosscuttingMembers cmembers = resolvedType.collectCrosscuttingMembers();
+ CrosscuttingMembers cmembers = resolvedType.collectCrosscuttingMembers(true);
List tmungers = cmembers.getTypeMungers();
return tmungers;
}
diff --git a/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java b/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java
index 67b599c87..460be02cd 100644
--- a/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java
+++ b/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java
@@ -44,7 +44,8 @@ public class Ajc152Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
// known failures, uncomment when working.
public void testReferencePCutInDeclareWarning_pr138215() { runTest("Reference pointcut fails inside @DeclareWarning");}
-// public void testReferencePCutInPerClause_pr138219() { runTest("Can't use a FQ Reference pointcut in any pointcut expression referenced by a per-clause");}
+ public void testReferencePCutInPerClause_pr138219() { runTest("Can't use a FQ Reference pointcut in any pointcut expression referenced by a per-clause");}
+ public void testReferencePCutInPerClause_pr130722() { runTest("FQ Reference pointcut from perclause ref pc"); }
// public void testDoubleAnnotationMatching_pr138223() { runTest("Double at annotation matching (no binding)");}
public void testSuperCallsInAtAspectJAdvice_pr139749() { runTest("Super calls in @AspectJ advice");}
diff --git a/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml b/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml
index ee5ec2ded..6378b42ca 100644
--- a/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml
+++ b/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml
@@ -202,8 +202,18 @@
</ajc-test>
<ajc-test dir="bugs152/pr138219" pr="138219" title="Can't use a FQ Reference pointcut in any pointcut expression referenced by a per-clause">
- <compile files="PerThisWithReference.aj,SomeOtherType.aj" options="-1.5">
+ <compile files="PerThisWithReference.aj,SomeOtherType.aj,RegularPCWithReference.aj" options="-1.5">
</compile>
+ <run class="PerThisWithReference">
+ <stdout>
+ <line text="before PerThisWithReference:1"/>
+ <line text="before PerThisWithReference:2"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="bugs152/pr130722" pr="130722" title="FQ Reference pointcut from perclause ref pc">
+ <compile files="test/Test.java,test/PointcutConsumer.aj,test1/PointcutProvider.aj"/>
</ajc-test>
<ajc-test dir="bugs152/pr138220" pr="138220" title="@Aspect with reference pointcut in perclause">
diff --git a/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java b/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java
index 46b6ada85..d96842d10 100644
--- a/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java
+++ b/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java
@@ -63,9 +63,12 @@ public class CrosscuttingMembers {
private List declareAnnotationsOnField = new ArrayList();
private List declareAnnotationsOnMethods = new ArrayList(); // includes ctors
- public CrosscuttingMembers(ResolvedType inAspect) {
+ private boolean shouldConcretizeIfNeeded = true;
+
+ public CrosscuttingMembers(ResolvedType inAspect, boolean shouldConcretizeIfNeeded) {
this.inAspect = inAspect;
this.world = inAspect.getWorld();
+ this.shouldConcretizeIfNeeded = shouldConcretizeIfNeeded;
}
// public void addConcreteShadowMungers(Collection c) {
@@ -214,9 +217,11 @@ public class CrosscuttingMembers {
public boolean replaceWith(CrosscuttingMembers other,boolean careAboutShadowMungers) {
boolean changed = false;
- if (perClause == null || !perClause.equals(other.perClause)) {
- changed = true;
- perClause = other.perClause;
+ if (careAboutShadowMungers) {
+ if (perClause == null || !perClause.equals(other.perClause)) {
+ changed = true;
+ perClause = other.perClause;
+ }
}
//XXX all of the below should be set equality rather than list equality
@@ -357,12 +362,12 @@ public class CrosscuttingMembers {
return changed;
}
- public PerClause getPerClause() {
- return perClause;
- }
-
public void setPerClause(PerClause perClause) {
- this.perClause = perClause.concretize(inAspect);
+ if (this.shouldConcretizeIfNeeded) {
+ this.perClause = perClause.concretize(inAspect);
+ } else {
+ this.perClause = perClause;
+ }
}
public List getDeclareDominates() {
diff --git a/weaver/src/org/aspectj/weaver/CrosscuttingMembersSet.java b/weaver/src/org/aspectj/weaver/CrosscuttingMembersSet.java
index 2b7c4ff32..1861022b9 100644
--- a/weaver/src/org/aspectj/weaver/CrosscuttingMembersSet.java
+++ b/weaver/src/org/aspectj/weaver/CrosscuttingMembersSet.java
@@ -61,22 +61,22 @@ public class CrosscuttingMembersSet {
* @return whether or not that was a change to the global signature
* XXX for efficiency we will need a richer representation than this
*/
- public boolean addOrReplaceAspect(ResolvedType aspectType,boolean careAboutShadowMungers) {
+ public boolean addOrReplaceAspect(ResolvedType aspectType, boolean inWeavingPhase) {
boolean change = false;
CrosscuttingMembers xcut = (CrosscuttingMembers)members.get(aspectType);
if (xcut == null) {
- members.put(aspectType, aspectType.collectCrosscuttingMembers());
+ members.put(aspectType, aspectType.collectCrosscuttingMembers(inWeavingPhase));
clearCaches();
CflowPointcut.clearCaches(aspectType);
change = true;
} else {
- if (xcut.replaceWith(aspectType.collectCrosscuttingMembers(),careAboutShadowMungers)) {
+ if (xcut.replaceWith(aspectType.collectCrosscuttingMembers(inWeavingPhase),inWeavingPhase)) {
clearCaches();
CflowPointcut.clearCaches(aspectType);
change = true;
} else {
- if (!World.compareLocations && careAboutShadowMungers) {
+ if (!World.compareLocations && inWeavingPhase) {
// bug 134541 - even though we haven't changed we may have updated the
// sourcelocation for the shadowMunger which we need to pick up
shadowMungers = null;
@@ -86,14 +86,14 @@ public class CrosscuttingMembersSet {
}
if (aspectType.isAbstract()) {
// we might have sub-aspects that need to re-collect their crosscutting members from us
- boolean ancestorChange = addOrReplaceDescendantsOf(aspectType,careAboutShadowMungers);
+ boolean ancestorChange = addOrReplaceDescendantsOf(aspectType,inWeavingPhase);
change = change || ancestorChange;
}
changedSinceLastReset = changedSinceLastReset || change;
return change;
}
- private boolean addOrReplaceDescendantsOf(ResolvedType aspectType,boolean careAboutShadowMungers) {
+ private boolean addOrReplaceDescendantsOf(ResolvedType aspectType, boolean inWeavePhase) {
//System.err.println("Looking at descendants of "+aspectType.getName());
Set knownAspects = members.keySet();
Set toBeReplaced = new HashSet();
@@ -106,7 +106,7 @@ public class CrosscuttingMembersSet {
boolean change = false;
for (Iterator it = toBeReplaced.iterator(); it.hasNext(); ) {
ResolvedType next = (ResolvedType)it.next();
- boolean thisChange = addOrReplaceAspect(next,careAboutShadowMungers);
+ boolean thisChange = addOrReplaceAspect(next,inWeavePhase);
change = change || thisChange;
}
return change;
diff --git a/weaver/src/org/aspectj/weaver/ResolvedType.java b/weaver/src/org/aspectj/weaver/ResolvedType.java
index d220bcb0c..84da56906 100644
--- a/weaver/src/org/aspectj/weaver/ResolvedType.java
+++ b/weaver/src/org/aspectj/weaver/ResolvedType.java
@@ -498,8 +498,8 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
//??? collecting data-structure, shouldn't really be a field
public CrosscuttingMembers crosscuttingMembers;
- public CrosscuttingMembers collectCrosscuttingMembers() {
- crosscuttingMembers = new CrosscuttingMembers(this);
+ public CrosscuttingMembers collectCrosscuttingMembers(boolean shouldConcretizeIfNeeded) {
+ crosscuttingMembers = new CrosscuttingMembers(this,shouldConcretizeIfNeeded);
crosscuttingMembers.setPerClause(getPerClause());
crosscuttingMembers.addShadowMungers(collectShadowMungers());
crosscuttingMembers.addTypeMungers(getTypeMungers());
diff --git a/weaver/testsrc/org/aspectj/weaver/bcel/NonstaticWeaveTestCase.java b/weaver/testsrc/org/aspectj/weaver/bcel/NonstaticWeaveTestCase.java
index 0a35627de..3559f8f5f 100644
--- a/weaver/testsrc/org/aspectj/weaver/bcel/NonstaticWeaveTestCase.java
+++ b/weaver/testsrc/org/aspectj/weaver/bcel/NonstaticWeaveTestCase.java
@@ -45,7 +45,7 @@ public class NonstaticWeaveTestCase extends WeaveTestCase {
per.resolve(new TestScope(new String[0], new String[0], world));
ResolvedType onAspect = world.resolve("Aspect");
- CrosscuttingMembers xcut = new CrosscuttingMembers(onAspect);
+ CrosscuttingMembers xcut = new CrosscuttingMembers(onAspect,true);
onAspect.crosscuttingMembers = xcut;
per = per.concretize(onAspect);
@@ -64,7 +64,7 @@ public class NonstaticWeaveTestCase extends WeaveTestCase {
per.resolve(new TestScope(new String[0], new String[0], world));
ResolvedType onAspect = world.resolve("Aspect");
- CrosscuttingMembers xcut = new CrosscuttingMembers(onAspect);
+ CrosscuttingMembers xcut = new CrosscuttingMembers(onAspect,true);
onAspect.crosscuttingMembers = xcut;
per = per.concretize(onAspect);
diff --git a/weaver/testsrc/org/aspectj/weaver/bcel/PointcutResidueTestCase.java b/weaver/testsrc/org/aspectj/weaver/bcel/PointcutResidueTestCase.java
index 3c2701241..3bec378af 100644
--- a/weaver/testsrc/org/aspectj/weaver/bcel/PointcutResidueTestCase.java
+++ b/weaver/testsrc/org/aspectj/weaver/bcel/PointcutResidueTestCase.java
@@ -196,7 +196,7 @@ public class PointcutResidueTestCase extends WeaveTestCase {
0, -1, -1, null, null);
ResolvedType inAspect = world.resolve("Aspect");
- CrosscuttingMembers xcut = new CrosscuttingMembers(inAspect);
+ CrosscuttingMembers xcut = new CrosscuttingMembers(inAspect,true);
inAspect.crosscuttingMembers = xcut;
ShadowMunger cp = pp.concretize(inAspect, world, null);
diff --git a/weaver/testsrc/org/aspectj/weaver/bcel/WeaveOrderTestCase.java b/weaver/testsrc/org/aspectj/weaver/bcel/WeaveOrderTestCase.java
index 5976acd03..89c1b2e29 100644
--- a/weaver/testsrc/org/aspectj/weaver/bcel/WeaveOrderTestCase.java
+++ b/weaver/testsrc/org/aspectj/weaver/bcel/WeaveOrderTestCase.java
@@ -80,7 +80,7 @@ public class WeaveOrderTestCase extends WeaveTestCase {
new PatternParser("declare precedence: java.lang.String, java.lang.Throwable").parseDeclare();
//??? concretize dom
ResolvedType aType = world.resolve("Aspect");
- CrosscuttingMembers xcut = new CrosscuttingMembers(aType);
+ CrosscuttingMembers xcut = new CrosscuttingMembers(aType,true);
aType.crosscuttingMembers = xcut;
xcut.addDeclare(dom);
world.getCrosscuttingMembersSet().addFixedCrosscuttingMembers(aType);
@@ -108,7 +108,7 @@ public class WeaveOrderTestCase extends WeaveTestCase {
new PatternParser("declare precedence: *, java.lang.String, java.lang.Throwable").parseDeclare();
//??? concretize dom
ResolvedType aType = world.resolve("Aspect");
- CrosscuttingMembers xcut = new CrosscuttingMembers(aType);
+ CrosscuttingMembers xcut = new CrosscuttingMembers(aType,true);
aType.crosscuttingMembers = xcut;
xcut.addDeclare(dom);
world.getCrosscuttingMembersSet().addFixedCrosscuttingMembers(aType);