From 9894a3d4826ef3480a53aa7cd8d86804af3f1fdd Mon Sep 17 00:00:00 2001 From: jhugunin Date: Tue, 22 Jul 2003 22:51:34 +0000 Subject: [PATCH] fix and expanded tests for Bugzilla Bug 39462 Compiler crashes in jar and cflow --- .../compiler/lookup/EclipseSourceType.java | 4 ++++ tests/ajcTests.xml | 17 +++++++++++++++++ tests/ajcTestsFailing.xml | 7 +------ tests/bugs/cflowAndJar/AbstractAspect.aj | 9 ++++++++- tests/bugs/cflowAndJar/Test.java | 11 +++++++++-- tests/bugs/cflowAndJar/TestAspect.aj | 11 ++++++++++- tests/bugs/cflowAndJar/lib.jar | Bin 662 -> 662 bytes .../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 @@ + + + + + + + + + + + + + + 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 @@ - - - - + 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 index e80bb93b8058ef5327e8d8b79b2074dd98a9e746..46368f2d2463d78ff1a9d02859d7cee6c43419f6 100644 GIT binary patch delta 579 zcmV-J0=)f}1(pR3P)h>@6aWYS2mmI0_K^)Ge|=KPZWBQet+K~<;uvRPO@t62LqY`h z0U;qkNR|T!WU(j^ILxJIreoSnrmdc~&5a`$4*Uv2A`%BafREsS#4m6RydE2a6^D^t z*Y>8Wx~jh(eEvdtx<+eE)n<@dBSPCudor{oVy3087>GtJl1}4M(9OJgrs5ryD0`PF zf4^~MhskT{NLHvo#WHy`$F$g1iG0}K3#54}f><)Gv~?)r9buHS$4<|_R4Hn-rwiX^ zIxD(iEs(p~$l7$UcH<_~sy3av$n0)?D8)dUdNUfR5J{_vwsK1u#9AVbE41X=%F!}Y zd0Y2QDDNv*e0e%=U38f)&&c~&tHg$Vf4e2aSQufIPMFqa5Jv=gM0c6Vbbdx`)KyC- zR=x)1+ziU|Ol(_WrFQ|B@yLC7VmEZ0C0GqehAeFE)BFc0Ia5=2hAgq4cdxZR!X8PU?rdu^u*)=z%c)p(lk@ZV>Ch6W|%p1KtAf zfcL;hU?2Dfd`CZMoEK=-Z7BB}DNsuX2(^S@*8Bkg0G@6aWYS2mld+;*kv{e|1vJZc{N3JyTFN4`!1U%>{6? zf6K@sS3(8_hUK=3<;(Ffl;)U+kz}Z}wct^g8|D02Fk??uLKy9N;0D7MABbuwPqdNM z`DFFs1BOj)`ZezTL2WAeM4DQ&H&H^)P2BmASUJpNg$C7Q%dpY*Nu}#YM#Z*cjpV~d z85OJ*v5IwK)>DSM7I1}OZ9#D!*BJ66e;0^iYPjG22hLKs-#F-&aUC~G*u)k?siVh6 z$mhxtUY+Ms;{%4f3%DF<>MzFjsT2`6+$tUahqQMYb{6E$fm=GZ@;#MoFDQBAO~-O8 zGrLI9Q~%6^DRprB1M|M7tNN%wjbmccKo3WKZpw1 zJnlMnU0?PW|2DY-&svXy*`)+@*=m%?V5-f#WWJNy9v0BMs~0zaK92n7HD 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; } -- 2.39.5