From 9c38e399f5d9c75fdd2b918752fba7fa12b28673 Mon Sep 17 00:00:00 2001 From: aclement Date: Fri, 20 Jan 2006 09:40:54 +0000 Subject: [PATCH] 77166 - newarray joinpoint support. "-Xjoinpoints:arrayconstruction" --- .../systemtest/ajc151/AllTestsAspectJ151.java | 1 + .../ajc151/NewarrayJoinpointTests.java | 3 + .../systemtest/ajc151/newarray_joinpoint.xml | 7 +++ .../weaver/JoinPointSignatureIterator.java | 10 +++ weaver/src/org/aspectj/weaver/Shadow.java | 22 +++++++ weaver/src/org/aspectj/weaver/World.java | 1 + .../aspectj/weaver/bcel/BcelClassWeaver.java | 38 +++++++++++- .../org/aspectj/weaver/bcel/BcelShadow.java | 61 ++++++++++++++++--- .../aspectj/weaver/patterns/ArgsPointcut.java | 7 ++- 9 files changed, 141 insertions(+), 9 deletions(-) diff --git a/tests/src/org/aspectj/systemtest/ajc151/AllTestsAspectJ151.java b/tests/src/org/aspectj/systemtest/ajc151/AllTestsAspectJ151.java index 31d37c5d5..1153be1b6 100644 --- a/tests/src/org/aspectj/systemtest/ajc151/AllTestsAspectJ151.java +++ b/tests/src/org/aspectj/systemtest/ajc151/AllTestsAspectJ151.java @@ -19,6 +19,7 @@ public class AllTestsAspectJ151 { TestSuite suite = new TestSuite("AspectJ 1.5.1 tests"); //$JUnit-BEGIN$ suite.addTest(Ajc151Tests.suite()); + suite.addTest(NewarrayJoinpointTests.suite()); //$JUnit-END$ return suite; } diff --git a/tests/src/org/aspectj/systemtest/ajc151/NewarrayJoinpointTests.java b/tests/src/org/aspectj/systemtest/ajc151/NewarrayJoinpointTests.java index dbd0be4da..4db134003 100644 --- a/tests/src/org/aspectj/systemtest/ajc151/NewarrayJoinpointTests.java +++ b/tests/src/org/aspectj/systemtest/ajc151/NewarrayJoinpointTests.java @@ -60,6 +60,9 @@ public class NewarrayJoinpointTests extends XMLBasedAjcTestCase { public void testUsingItForReal() { runTest("using it for real");} public void testDifferentiatingArrayTypes() { runTest("differentiating array types");} public void testStructureModel() { runTest("structure model");} + + + public void testOptionoff() { runTest("option deactivated - no match expected");} // public static Test suite() { diff --git a/tests/src/org/aspectj/systemtest/ajc151/newarray_joinpoint.xml b/tests/src/org/aspectj/systemtest/ajc151/newarray_joinpoint.xml index fedc67322..b75d4adec 100644 --- a/tests/src/org/aspectj/systemtest/ajc151/newarray_joinpoint.xml +++ b/tests/src/org/aspectj/systemtest/ajc151/newarray_joinpoint.xml @@ -153,5 +153,12 @@ + + + + + + + \ No newline at end of file diff --git a/weaver/src/org/aspectj/weaver/JoinPointSignatureIterator.java b/weaver/src/org/aspectj/weaver/JoinPointSignatureIterator.java index b11f41f80..265f6f4e0 100644 --- a/weaver/src/org/aspectj/weaver/JoinPointSignatureIterator.java +++ b/weaver/src/org/aspectj/weaver/JoinPointSignatureIterator.java @@ -96,7 +96,17 @@ public class JoinPointSignatureIterator implements Iterator { // Walk up hierarchy creating one member for each type up to and including the // first defining type ResolvedType originalDeclaringType = signaturesOfMember.getDeclaringType().resolve(world); + + if (world.isJoinpointArrayConstructionEnabled() && originalDeclaringType.isArray()) { // Aha, this must be the array constructor call join point - a 'special'... + Member m = signaturesOfMember; + ResolvedMember rm = new ResolvedMemberImpl(m.getKind(),m.getDeclaringType(),m.getModifiers(),m.getReturnType(),m.getName(),m.getParameterTypes()); + discoveredSignatures.add(new JoinPointSignature(rm,originalDeclaringType)); + couldBeFurtherAsYetUndiscoveredSignatures = false; + return; + } + firstDefiningMember = (ResolvedMemberImpl) signaturesOfMember.resolve(world); + if (firstDefiningMember == null) { couldBeFurtherAsYetUndiscoveredSignatures = false; return; diff --git a/weaver/src/org/aspectj/weaver/Shadow.java b/weaver/src/org/aspectj/weaver/Shadow.java index 4d28fbe59..ab652b24c 100644 --- a/weaver/src/org/aspectj/weaver/Shadow.java +++ b/weaver/src/org/aspectj/weaver/Shadow.java @@ -142,7 +142,29 @@ public abstract class Shadow { return getSignature().getParameterTypes(); } + public boolean isShadowForArrayConstructionJoinpoint() { + return (getKind()==ConstructorCall && signature.getDeclaringType().isArray()); + } + + // will return the right length array of ints depending on how many dimensions the array has + public ResolvedType[] getArgumentTypesForArrayConstructionShadow() { + String s = signature.getDeclaringType().getSignature(); + int pos = s.indexOf("["); + int dims = 1; + while (pos