]> source.dussan.org Git - aspectj.git/commitdiff
tests and fixes for 160469: handle problems
authoraclement <aclement>
Mon, 16 Oct 2006 13:04:42 +0000 (13:04 +0000)
committeraclement <aclement>
Mon, 16 Oct 2006 13:04:42 +0000 (13:04 +0000)
17 files changed:
tests/model/expected/pr160469_1.txt [new file with mode: 0644]
tests/model/expected/pr160469_2.txt [new file with mode: 0644]
tests/model/pr160469_1/AbstractBeanConfigurerAspect.aj [new file with mode: 0644]
tests/model/pr160469_1/AnnotationBeanConfigurerAspect.aj [new file with mode: 0644]
tests/model/pr160469_1/README.txt [new file with mode: 0644]
tests/model/pr160469_1/Simple.java [new file with mode: 0644]
tests/model/pr160469_1/aspects.jar [new file with mode: 0644]
tests/model/pr160469_2/AbstractBeanConfigurerAspect.aj [new file with mode: 0644]
tests/model/pr160469_2/AnnotationBeanConfigurerAspect.aj [new file with mode: 0644]
tests/model/pr160469_2/README.txt [new file with mode: 0644]
tests/model/pr160469_2/Simple.java [new file with mode: 0644]
tests/model/pr160469_2/aspects.jar [new file with mode: 0644]
tests/src/org/aspectj/systemtest/model/ModelTests.java
tests/src/org/aspectj/systemtest/model/model.xml
weaver/src/org/aspectj/weaver/Advice.java
weaver/src/org/aspectj/weaver/Checker.java
weaver/src/org/aspectj/weaver/ShadowMunger.java

diff --git a/tests/model/expected/pr160469_1.txt b/tests/model/expected/pr160469_1.txt
new file mode 100644 (file)
index 0000000..7a0d908
--- /dev/null
@@ -0,0 +1,32 @@
+=== MODEL STATUS REPORT ========= After a batch build
+<root>  [java source file] 
+  test  [package] 
+    Simple.java  [java source file] TEST_SANDBOX\Simple.java:1:
+      import declarations  [import reference] 
+      Simple  [class] TEST_SANDBOX\Simple.java:3:
+        Simple()  [constructor] TEST_SANDBOX\Simple.java:5:
+  pkg  [package] 
+    AbstractBeanConfigurerAspect.class (binary)  [class] TEST_SANDBOX\aspects.jar!pkg\AbstractBeanConfigurerAspect.class:1:
+      import declarations  [import reference] 
+      AbstractBeanConfigurerAspect  [aspect] TEST_SANDBOX\aspects.jar!pkg\AbstractBeanConfigurerAspect.class:1:
+        beanCreation()  [pointcut] TEST_SANDBOX\aspects.jar!pkg\AbstractBeanConfigurerAspect.class:1:
+        afterReturning(): beanCreation..  [advice] TEST_SANDBOX\aspects.jar!pkg\AbstractBeanConfigurerAspect.class:6:
+        before(): beanCreation..  [advice] TEST_SANDBOX\aspects.jar!pkg\AbstractBeanConfigurerAspect.class:11:
+=== END OF MODEL REPORT =========
+=== RELATIONSHIPS REPORT ========= After a batch build
+(targets=1) <pkg[AbstractBeanConfigurerAspect.class (binary)}AbstractBeanConfigurerAspect&afterReturning (advises) <test{Simple.java[Simple~Simple
+(targets=1) <pkg[AbstractBeanConfigurerAspect.class (binary)}AbstractBeanConfigurerAspect&before (advises) <test{Simple.java[Simple~Simple
+(targets=2) <test{Simple.java[Simple~Simple (advised by) <pkg[AbstractBeanConfigurerAspect.class (binary)}AbstractBeanConfigurerAspect&afterReturning
+(targets=2) <test{Simple.java[Simple~Simple (advised by) <pkg[AbstractBeanConfigurerAspect.class (binary)}AbstractBeanConfigurerAspect&before
+=== END OF RELATIONSHIPS REPORT ==
+=== Properties of the model and relationships map =====
+import reference=2
+aspect=1
+constructor=1
+class=2
+advice=2
+pointcut=1
+RelationshipMapSize=3
+FileMapSize=1
+package=2
+java source file=2
diff --git a/tests/model/expected/pr160469_2.txt b/tests/model/expected/pr160469_2.txt
new file mode 100644 (file)
index 0000000..9ea2154
--- /dev/null
@@ -0,0 +1,29 @@
+=== MODEL STATUS REPORT ========= After a batch build
+<root>  [java source file] 
+  test  [package] 
+    Simple.java  [java source file] TEST_SANDBOX\Simple.java:1:
+      import declarations  [import reference] 
+      Simple  [class] TEST_SANDBOX\Simple.java:3:
+        Simple()  [constructor] TEST_SANDBOX\Simple.java:5:
+  pkg  [package] 
+    AbstractBeanConfigurerAspect.class (binary)  [class] TEST_SANDBOX\aspects.jar!pkg\AbstractBeanConfigurerAspect.class:1:
+      import declarations  [import reference] 
+      AbstractBeanConfigurerAspect  [aspect] TEST_SANDBOX\aspects.jar!pkg\AbstractBeanConfigurerAspect.class:1:
+        beanCreation()  [pointcut] TEST_SANDBOX\aspects.jar!pkg\AbstractBeanConfigurerAspect.class:1:
+        declare warning: "warning"  [declare warning] TEST_SANDBOX\aspects.jar!pkg\AbstractBeanConfigurerAspect.class:7:
+=== END OF MODEL REPORT =========
+=== RELATIONSHIPS REPORT ========= After a batch build
+(targets=1) <pkg[AbstractBeanConfigurerAspect.class (binary)}AbstractBeanConfigurerAspect`declare warning (matched by) <test{Simple.java[Simple~Simple
+(targets=1) <test{Simple.java[Simple~Simple (matches declare) <pkg[AbstractBeanConfigurerAspect.class (binary)}AbstractBeanConfigurerAspect`declare warning
+=== END OF RELATIONSHIPS REPORT ==
+=== Properties of the model and relationships map =====
+import reference=2
+aspect=1
+declare warning=1
+constructor=1
+class=2
+pointcut=1
+RelationshipMapSize=2
+FileMapSize=1
+package=2
+java source file=2
diff --git a/tests/model/pr160469_1/AbstractBeanConfigurerAspect.aj b/tests/model/pr160469_1/AbstractBeanConfigurerAspect.aj
new file mode 100644 (file)
index 0000000..adaec24
--- /dev/null
@@ -0,0 +1,14 @@
+package pkg;
+
+public abstract aspect AbstractBeanConfigurerAspect {
+
+       // advice starts on line 6
+       after() returning : beanCreation() {
+       }
+       
+       protected abstract pointcut beanCreation();
+
+       before() : beanCreation() {
+               
+       }       
+}
diff --git a/tests/model/pr160469_1/AnnotationBeanConfigurerAspect.aj b/tests/model/pr160469_1/AnnotationBeanConfigurerAspect.aj
new file mode 100644 (file)
index 0000000..832255c
--- /dev/null
@@ -0,0 +1,7 @@
+package pkg;
+
+public aspect AnnotationBeanConfigurerAspect extends AbstractBeanConfigurerAspect {
+       
+       // pointcut is on line 6
+       protected pointcut beanCreation() : initialization(*.new(..)) && !within(pkg.*);
+}
diff --git a/tests/model/pr160469_1/README.txt b/tests/model/pr160469_1/README.txt
new file mode 100644 (file)
index 0000000..e1d445a
--- /dev/null
@@ -0,0 +1,3 @@
+to regenerate the jar file in this directory:
+
+ajc AbstractBeanConfigurerAspect.aj AnnotationBeanConfigurerAspect.aj -outjar aspects.jar
diff --git a/tests/model/pr160469_1/Simple.java b/tests/model/pr160469_1/Simple.java
new file mode 100644 (file)
index 0000000..26b84d7
--- /dev/null
@@ -0,0 +1,8 @@
+package test;
+
+public class Simple {
+
+       public Simple() {       
+       }
+       
+}
diff --git a/tests/model/pr160469_1/aspects.jar b/tests/model/pr160469_1/aspects.jar
new file mode 100644 (file)
index 0000000..fd109bc
Binary files /dev/null and b/tests/model/pr160469_1/aspects.jar differ
diff --git a/tests/model/pr160469_2/AbstractBeanConfigurerAspect.aj b/tests/model/pr160469_2/AbstractBeanConfigurerAspect.aj
new file mode 100644 (file)
index 0000000..fae7687
--- /dev/null
@@ -0,0 +1,9 @@
+package pkg;
+
+public abstract aspect AbstractBeanConfigurerAspect {
+       
+       protected abstract pointcut beanCreation();
+
+       declare warning : beanCreation() : "warning";
+       
+}
diff --git a/tests/model/pr160469_2/AnnotationBeanConfigurerAspect.aj b/tests/model/pr160469_2/AnnotationBeanConfigurerAspect.aj
new file mode 100644 (file)
index 0000000..72877ef
--- /dev/null
@@ -0,0 +1,6 @@
+package pkg;
+
+public aspect AnnotationBeanConfigurerAspect extends AbstractBeanConfigurerAspect {
+       
+       protected pointcut beanCreation() : initialization(*.new(..)) && !within(pkg.*);
+}
diff --git a/tests/model/pr160469_2/README.txt b/tests/model/pr160469_2/README.txt
new file mode 100644 (file)
index 0000000..e1d445a
--- /dev/null
@@ -0,0 +1,3 @@
+to regenerate the jar file in this directory:
+
+ajc AbstractBeanConfigurerAspect.aj AnnotationBeanConfigurerAspect.aj -outjar aspects.jar
diff --git a/tests/model/pr160469_2/Simple.java b/tests/model/pr160469_2/Simple.java
new file mode 100644 (file)
index 0000000..26b84d7
--- /dev/null
@@ -0,0 +1,8 @@
+package test;
+
+public class Simple {
+
+       public Simple() {       
+       }
+       
+}
diff --git a/tests/model/pr160469_2/aspects.jar b/tests/model/pr160469_2/aspects.jar
new file mode 100644 (file)
index 0000000..ac74b57
Binary files /dev/null and b/tests/model/pr160469_2/aspects.jar differ
index 0ffa27a26ecdb2eed8e7b51129765dfd3193336b..51853f332483b55806aaf34aaafddfe3e682175e 100644 (file)
@@ -67,6 +67,8 @@ public class ModelTests extends ModelTestCase {
        public void testAspectInDefaultPackage_pr145963() {runModelTest("aspect in default package", "pr145963_3");}
        public void testAspectInJavaFile_pr145963() {runModelTest("aspect in java file", "pr145963_4");}
 
+       public void testAbstractAspectsAndAdvice_pr160469() {runModelTest("ensure advice from abstract aspects appear correctly in the model","pr160469_1");}
+       public void testAbstractAspectsAndDeow_pr160469() {runModelTest("ensure deow from abstract aspects appear correctly in the model","pr160469_2");}
        
        /////////////////////////////////////////
        public static Test suite() {
index 6cfd4cca998f571b11fe7cc623870e13d6d369bc..38bd461b7e922dd176e1061b02203fd6bb250f3a 100644 (file)
       <compile files="A.aj, C.aj" options="-emacssym"/>
     </ajc-test>
 
+       <ajc-test dir="model/pr160469_1" title="ensure advice from abstract aspects appear correctly in the model">
+      <compile files="Simple.java" options="-emacssym" aspectpath="aspects.jar"/>
+    </ajc-test>
+
+       <ajc-test dir="model/pr160469_2" title="ensure deow from abstract aspects appear correctly in the model">
+      <compile files="Simple.java" options="-emacssym" aspectpath="aspects.jar">
+               <message kind="warning" line="5" text="warning"/>
+      </compile>
+    </ajc-test>
 
 <!-- AspectJ 5 specific tests -->
 
index ba3bf6bcaf3bbaff16cca7200e5ce527888c1cab..0f5a8e7de375ecdaa924351a99a0af36aa51bd82 100644 (file)
@@ -364,6 +364,7 @@ public abstract class Advice extends ShadowMunger {
                Advice munger = world.createAdviceMunger(attribute, p, signature);
                munger.concreteAspect = fromType;
                munger.bindingParameterTypes = this.bindingParameterTypes;
+               munger.setDeclaringType(getDeclaringType());
        //System.err.println("concretizing here " + p + " with clause " + clause);
         return munger;
     }
@@ -431,9 +432,4 @@ public abstract class Advice extends ShadowMunger {
                return concreteAspect;
        }
        
-       public ResolvedType getResolvedDeclaringAspect() {
-               // The aspect which declares this piece of advice 
-               // is 'concreteAspect' since 'declaringType' is null
-               return ((concreteAspect != null) ? concreteAspect : getDeclaringType());
-       }
 }
index 6dd5fd9b02b9de8a943aaa16dc6d8feb9026e705..b7990c88c9f2d808b6fd8f6646aa8a07f3976a71 100644 (file)
@@ -135,8 +135,4 @@ public class Checker extends ShadowMunger {
                return isError;
        }
 
-       public ResolvedType getResolvedDeclaringAspect() {
-               // The aspect which declares this deow is the declaring type
-               return getDeclaringType();
-       }
 }
index a376187a6df54d38f450325f06c4d94e8692688b..bffb9f45dcedf3e8a7250c72c72dec31307c9f80 100644 (file)
@@ -156,12 +156,6 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH
      */
     public abstract boolean mustCheckExceptions();
     
-    /**
-     * Returns the ResolvedType corresponding to the aspect in which this
-     * shadowMunger is declared. This is different for deow's and advice.
-     */
-    public abstract ResolvedType getResolvedDeclaringAspect();
-    
     /**
      * Creates the hierarchy for binary aspects
      */
@@ -177,7 +171,7 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH
                        return;
                }
        
-       ResolvedType aspect = getResolvedDeclaringAspect();
+       ResolvedType aspect = getDeclaringType();
        
        // create the class file node
        IProgramElement classFileNode = new ProgramElement(
@@ -261,10 +255,14 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH
                        ResolvedMember pcd = children[i];
                        if (pcd instanceof ResolvedPointcutDefinition) {
                                ResolvedPointcutDefinition rpcd = (ResolvedPointcutDefinition)pcd;
+                               ISourceLocation sLoc = rpcd.getPointcut().getSourceLocation();
+                               if (sLoc == null) {
+                                       sLoc = rpcd.getSourceLocation();
+                               }
                                parent.addChild(new ProgramElement(
                                                pcd.getName(),
                                                IProgramElement.Kind.POINTCUT,
-                                           getBinarySourceLocation(rpcd.getPointcut().getSourceLocation()),
+                                           getBinarySourceLocation(sLoc),
                                                pcd.getModifiers(),
                                                null,
                                                Collections.EMPTY_LIST));
@@ -341,8 +339,8 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH
     private ISourceLocation getBinarySourceLocation(ISourceLocation sl) {
        if (sl == null) return null;
        String sourceFileName = null;
-       if (getResolvedDeclaringAspect() instanceof ReferenceType) {
-                       String s = ((ReferenceType)getResolvedDeclaringAspect()).getDelegate().getSourcefilename();
+       if (getDeclaringType() instanceof ReferenceType) {
+                       String s = ((ReferenceType)getDeclaringType()).getDelegate().getSourcefilename();
                        int i = s.lastIndexOf('/');
                        if (i != -1) {
                                sourceFileName = s.substring(i+1);
@@ -369,8 +367,8 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH
      */
     private File getBinaryFile() {
        if (binaryFile == null) {
-               String s = getResolvedDeclaringAspect().getBinaryPath();
-               File f = getResolvedDeclaringAspect().getSourceLocation().getSourceFile();
+               String s = getDeclaringType().getBinaryPath();
+               File f = getDeclaringType().getSourceLocation().getSourceFile();
                int i = f.getPath().lastIndexOf('.');
                String path = f.getPath().substring(0,i) + ".class";
                binaryFile =  new File(s + "!" + path);
@@ -386,7 +384,7 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH
      */
     protected boolean isBinary() {
        if (!checkedIsBinary) {
-               ResolvedType rt = getResolvedDeclaringAspect();
+               ResolvedType rt = getDeclaringType();
                if (rt != null) {
                        isBinary = ((rt.getBinaryPath() == null) ? false : true);
                }