diff options
-rw-r--r-- | org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java | 4 | ||||
-rw-r--r-- | tests/ajcTests.xml | 17 | ||||
-rw-r--r-- | tests/ajcTestsFailing.xml | 7 | ||||
-rw-r--r-- | tests/bugs/cflowAndJar/AbstractAspect.aj | 9 | ||||
-rw-r--r-- | tests/bugs/cflowAndJar/Test.java | 11 | ||||
-rw-r--r-- | tests/bugs/cflowAndJar/TestAspect.aj | 11 | ||||
-rw-r--r-- | tests/bugs/cflowAndJar/lib.jar | bin | 662 -> 662 bytes | |||
-rw-r--r-- | weaver/src/org/aspectj/weaver/ResolvedTypeX.java | 18 |
8 files changed, 66 insertions, 11 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java index 4b598afce..e965ea031 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java @@ -228,4 +228,8 @@ public class EclipseSourceType extends ResolvedTypeX.ConcreteName { return typeMungers; } + public boolean doesNotExposeShadowMungers() { + return true; + } + } diff --git a/tests/ajcTests.xml b/tests/ajcTests.xml index 3f01a7cb6..e133841a2 100644 --- a/tests/ajcTests.xml +++ b/tests/ajcTests.xml @@ -6433,4 +6433,21 @@ <message kind="error" line="14"/> </compile> </ajc-test> + + <ajc-test dir="bugs/cflowAndJar" pr="39462" + title="Compiler crashes in jar and cflow (with no .jar)"> + <compile files="TestAspect.aj,Test.java,AbstractAspect.aj"> + <message kind="warning" line="16"/> + </compile> + <run class="Test"/> + </ajc-test> + + <ajc-test dir="bugs/cflowAndJar" pr="39462" + title="Compiler crashes in jar and cflow (with .jar)" + comment="make lib.jar with ajc -outjar lib.jar AbstractAspect.aj"> + <compile files="TestAspect.aj,Test.java" aspectpath="lib.jar"> + <message kind="warning" line="16"/> + </compile> + <run class="Test"/> + </ajc-test> </suite> diff --git a/tests/ajcTestsFailing.xml b/tests/ajcTestsFailing.xml index 4292bacbd..cb741c1e0 100644 --- a/tests/ajcTestsFailing.xml +++ b/tests/ajcTestsFailing.xml @@ -3,11 +3,6 @@ <!-- contains valid tests that the compiler has never passed --> <suite> - <ajc-test dir="bugs/cflowAndJar" pr="39462" - title="Compiler crashes in jar and cflow" - comment="make lib.jar with ajc -outjar lib.jar AbstractAspect.aj"> - <compile files="lib.jar,TestAspect.aj,Test.java"/> - <run class="Test"/> - </ajc-test> + </suite> diff --git a/tests/bugs/cflowAndJar/AbstractAspect.aj b/tests/bugs/cflowAndJar/AbstractAspect.aj index 529cc08b6..24e786213 100644 --- a/tests/bugs/cflowAndJar/AbstractAspect.aj +++ b/tests/bugs/cflowAndJar/AbstractAspect.aj @@ -1,6 +1,13 @@ public abstract aspect AbstractAspect{
public abstract pointcut directCall();
+
before(): directCall(){
- System.out.println("direct");
+ noteDirectCall();
}
+
+ abstract void noteDirectCall();
+
+ public abstract pointcut badCall();
+
+ declare warning: badCall(): "bad";
}
diff --git a/tests/bugs/cflowAndJar/Test.java b/tests/bugs/cflowAndJar/Test.java index 079ac6b22..9349ca4b0 100644 --- a/tests/bugs/cflowAndJar/Test.java +++ b/tests/bugs/cflowAndJar/Test.java @@ -1,8 +1,15 @@ -public class Test{ +import org.aspectj.testing.Tester; + +public class Test { public static void main(String[] arguments){ Test test = new Test(); - test.sayHello(); + Tester.checkEqual(TestAspect.sawDirectCall, false, "no calls"); + test.doSayHello(); + Tester.checkEqual(TestAspect.sawDirectCall, false, "non-cflow"); + + test.sayHello(); + Tester.checkEqual(TestAspect.sawDirectCall, true, "in-cflow"); } public void sayHello(){ diff --git a/tests/bugs/cflowAndJar/TestAspect.aj b/tests/bugs/cflowAndJar/TestAspect.aj index a6ed50ae6..78c93e86a 100644 --- a/tests/bugs/cflowAndJar/TestAspect.aj +++ b/tests/bugs/cflowAndJar/TestAspect.aj @@ -1,6 +1,15 @@ public aspect TestAspect extends AbstractAspect{
public pointcut directCall():
execution(void Test.doSayHello(..))
- && cflow(execution(void Test.direct(..)))
+ && cflow(execution(void Test.sayHello(..)))
;
+
+ public pointcut badCall():
+ call(void Test.doSayHello(..)) && withincode(void Test.sayHello(..));
+
+ void noteDirectCall() {
+ sawDirectCall = true;
+ }
+
+ public static boolean sawDirectCall = false;
}
diff --git a/tests/bugs/cflowAndJar/lib.jar b/tests/bugs/cflowAndJar/lib.jar Binary files differindex e80bb93b8..46368f2d2 100644 --- a/tests/bugs/cflowAndJar/lib.jar +++ b/tests/bugs/cflowAndJar/lib.jar diff --git a/weaver/src/org/aspectj/weaver/ResolvedTypeX.java b/weaver/src/org/aspectj/weaver/ResolvedTypeX.java index 9de2348ea..12bab5521 100644 --- a/weaver/src/org/aspectj/weaver/ResolvedTypeX.java +++ b/weaver/src/org/aspectj/weaver/ResolvedTypeX.java @@ -372,7 +372,7 @@ public abstract class ResolvedTypeX extends TypeX { private final Collection collectShadowMungers() { - if (! this.isAspect() || this.isAbstract()) return Collections.EMPTY_LIST; + if (! this.isAspect() || this.isAbstract() || this.doesNotExposeShadowMungers()) return Collections.EMPTY_LIST; ArrayList acc = new ArrayList(); final Iterators.Filter dupFilter = Iterators.dupFilter(); @@ -393,6 +393,10 @@ public abstract class ResolvedTypeX extends TypeX { return acc; } + protected boolean doesNotExposeShadowMungers() { + return false; + } + public PerClause getPerClause() { return null; } protected Collection getDeclares() { return Collections.EMPTY_LIST; @@ -633,6 +637,10 @@ public abstract class ResolvedTypeX extends TypeX { public void setStartPos(int startPos) { this.startPos = startPos; } + + public boolean doesNotExposeShadowMungers() { + return delegate.doesNotExposeShadowMungers(); + } } @@ -682,6 +690,14 @@ public abstract class ResolvedTypeX extends TypeX { // return sourceContext; // } + /** + * Designed to be overriden by EclipseType to disable collection of shadow mungers + * during pre-weave compilation phase + */ + public boolean doesNotExposeShadowMungers() { + return false; + } + public boolean isExposedToWeaver() { return exposedToWeaver; } |