]> source.dussan.org Git - aspectj.git/commitdiff
77166 - newarray joinpoint support. "-Xjoinpoints:arrayconstruction"
authoraclement <aclement>
Fri, 20 Jan 2006 10:52:29 +0000 (10:52 +0000)
committeraclement <aclement>
Fri, 20 Jan 2006 10:52:29 +0000 (10:52 +0000)
tests/src/org/aspectj/systemtest/ajc151/NewarrayJoinpointTests.java
tests/src/org/aspectj/systemtest/ajc151/newarray_joinpoint.xml
weaver/src/org/aspectj/weaver/WeaverMessages.java
weaver/src/org/aspectj/weaver/patterns/KindedPointcut.java
weaver/src/org/aspectj/weaver/weaver-messages.properties

index 4db1340038abcf263d27de9e2689f88cfed88b97..b4c363d81ce55ca743c3ee363aa0f9c7cc94e453 100644 (file)
 package org.aspectj.systemtest.ajc151;
 
 import java.io.File;
+import java.util.List;
 
 import junit.framework.Test;
 
+import org.aspectj.asm.AsmManager;
+import org.aspectj.asm.IProgramElement;
 import org.aspectj.testing.XMLBasedAjcTestCase;
 
 /*
@@ -55,14 +58,29 @@ public class NewarrayJoinpointTests extends XMLBasedAjcTestCase {
   public void testBasicWithAMultiDimensionalArray() { runTest("multi dimensional array creation"); }
   public void testArgsWithAMultiDimensionalArray() { runTest("multi dimensional array args");}
 
-  // complicated
+  // various
+  public void testOptionoff() { runTest("option deactivated - no match expected");}
   public void testUsingTargetAndAfterReturningAdvice() { runTest("using target and after returning");}
   public void testUsingItForReal() { runTest("using it for real");}
   public void testDifferentiatingArrayTypes() { runTest("differentiating array types");}
-  public void testStructureModel() { runTest("structure model");}
+  
+  public void testStructureModel() {  
+       //AsmManager.setReporting("c:/foo.txt",true,true,true,true);
+       runTest("structure model");
+       IProgramElement ipe = AsmManager.getDefault().getHierarchy().findElementForType("","Five");
+       assertTrue("Couldnt find 'Five' type in the model",ipe!=null);
+       List kids = ipe.getChildren();
+       assertTrue("Couldn't find 'main' method in the 'Five' type",kids!=null && kids.size()==1);
+       List codenodes = ((IProgramElement)kids.get(0)).getChildren();
+       assertTrue("Couldn't find nodes below 'main' method",codenodes!=null && codenodes.size()==1);
+       IProgramElement arrayCtorCallNode = (IProgramElement)codenodes.get(0);
+       String exp = "constructor-call(void java.lang.Integer[].<init>(int))";
+       assertTrue("Expected '"+exp+"' but found "+arrayCtorCallNode.toString(),arrayCtorCallNode.toString().equals(exp));
+       List rels = AsmManager.getDefault().getRelationshipMap().get(arrayCtorCallNode);
+       assertTrue("Should have a relationship from the ctorcall node, but didn't find one?",rels!=null && rels.size()==1);
+  }
   
   
-  public void testOptionoff() { runTest("option deactivated - no match expected");}
 
   //
   public static Test suite() {
index b75d4adec64f872d4087806b87e1c982e6d0e237..fb11fa5961c69994d2a81fe4f38265cf9b3b9b7b 100644 (file)
      <ajc-test dir="features151/newarrayjoinpoint" title="option deactivated - no match expected">
         <compile files="One.java" options="-1.5 -showWeaveInfo">
            <message kind="warning" line="9" text="advice defined in X has not been applied [Xlint:adviceDidNotMatch]"/>
+           <message kind="warning" line="9" text="There are no join points for array construction unless -Xjoinpoints:arrayconstruction is specified"/>
         </compile>
     </ajc-test>
     
index 8b0ecf8d4e807fc079e8fd399f421e3fa3fcdc89..7c0fdbb4f689b49e7aa6ce1a86d87e6b401ceb29 100644 (file)
@@ -31,6 +31,7 @@ public class WeaverMessages {
        public static final String CANT_BIND_TYPE = "cantBindType";
        public static final String WILDCARD_NOT_ALLOWED = "wildcardTypePatternNotAllowed";
        public static final String FIELDS_CANT_HAVE_VOID_TYPE = "fieldCantBeVoid";
+       public static final String NO_NEWARRAY_JOINPOINTS_BY_DEFAULT = "noNewArrayJoinpointsByDefault";
        
        public static final String DECP_OBJECT = "decpObject";
        public static final String CANT_EXTEND_SELF="cantExtendSelf";
index 0f124a7f99366ac2ac63aab4e5c106de394c85cf..25c25740c8aad5b268d24c049e74bbdaf0c19928 100644 (file)
@@ -358,7 +358,12 @@ public class KindedPointcut extends Pointcut {
                        if (visitor.wellHasItThen/*?*/()) {
                                scope.message(MessageUtil.error(WeaverMessages.format(WeaverMessages.NO_GENERIC_THROWABLES),
                                                getSourceLocation()));
-                       }                                                                       
+                       }                                                       
+                       if (!scope.getWorld().isJoinpointArrayConstructionEnabled() && 
+                               kind==Shadow.ConstructorCall &&
+                               signature.getDeclaringType().isArray()) {
+                               scope.message(MessageUtil.warn(WeaverMessages.format(WeaverMessages.NO_NEWARRAY_JOINPOINTS_BY_DEFAULT),getSourceLocation()));
+                       }
                }
        }
        
index c274d8f13940c2cfc17823c3d0f91576018d6639..3787c2693ba18b6cc42b9ba54a839eba54c50caa 100644 (file)
@@ -26,6 +26,7 @@ exactTypePatternRequired=exact type pattern required
 cantBindType=can''t bind type name ''{0}''
 wildcardTypePatternNotAllowed=wildcard type pattern not allowed, must use type name
 fieldCantBeVoid=fields cannot have a void type
+noNewArrayJoinpointsByDefault=There are no join points for array construction unless -Xjoinpoints:arrayconstruction is specified
 
 # Declare parents messages...
 decpObject=can''t change the parents of java.lang.Object