]> source.dussan.org Git - aspectj.git/commitdiff
263666: missing counter for around advice differing in return type
authoraclement <aclement>
Wed, 4 Feb 2009 21:19:30 +0000 (21:19 +0000)
committeraclement <aclement>
Wed, 4 Feb 2009 21:19:30 +0000 (21:19 +0000)
tests/src/org/aspectj/systemtest/ajc164/Ajc164Tests.java
tests/src/org/aspectj/systemtest/ajc164/ajc164.xml

index 124a005b0eb2aec5ae9f6e8f1f9f5d4f6c886498..6b0f35462bed7d74ac1b613ae8111374adcc775d 100644 (file)
@@ -11,6 +11,8 @@
 package org.aspectj.systemtest.ajc164;
 
 import java.io.File;
+import java.util.Iterator;
+import java.util.List;
 
 import junit.framework.Test;
 
@@ -20,10 +22,33 @@ import org.aspectj.apache.bcel.classfile.LocalVariableTable;
 import org.aspectj.apache.bcel.classfile.Method;
 import org.aspectj.apache.bcel.util.ClassPath;
 import org.aspectj.apache.bcel.util.SyntheticRepository;
+import org.aspectj.asm.AsmManager;
+import org.aspectj.asm.IHierarchy;
+import org.aspectj.asm.IProgramElement;
 import org.aspectj.testing.XMLBasedAjcTestCase;
 
 public class Ajc164Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
 
+       public void testHandles_pr263666() {
+               runTest("around advice handles");
+               IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy();
+               IProgramElement ipe = null;
+               ipe = findElementAtLine(top.getRoot(), 22);// public java.util.List<String> Ship.i(List<String>[][] u)
+               assertEquals("<x*OverrideOptions.aj}OverrideOptions&around", ipe.getHandleIdentifier());
+               ipe = findElementAtLine(top.getRoot(), 29);// public java.util.List<String> Ship.i(List<String>[][] u)
+               assertEquals("<x*OverrideOptions.aj}OverrideOptions&around!2", ipe.getHandleIdentifier());
+       }
+/*
+       // Only one of two aspects named
+       public void testAopConfig1() {
+               runTest("aop config - 1");
+       }
+
+       // Only one of two aspects named - and named one is scoped to only affect one type
+       public void testAopConfig2() {
+               runTest("aop config - 2");
+       }
+*/
        public void testAjcThisNotRead() {
                runTest("ajcthis not read");
        }
@@ -32,10 +57,6 @@ public class Ajc164Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
                runTest("recursive cflow");
        }
 
-       // public void testAopConfig1() {
-       // runTest("aop config - 1");
-       // }
-
        public void testAnnoDecprecedence_pr256779() {
                runTest("anno decprecedence");
        }
@@ -261,4 +282,25 @@ public class Ajc164Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
 
                return sb.toString();
        }
+
+       private IProgramElement findElementAtLine(IProgramElement whereToLook, int line) {
+               if (whereToLook == null) {
+                       return null;
+               }
+               if (whereToLook.getSourceLocation() != null && whereToLook.getSourceLocation().getLine() == line) {
+                       return whereToLook;
+               }
+               List kids = whereToLook.getChildren();
+               for (Iterator iterator = kids.iterator(); iterator.hasNext();) {
+                       IProgramElement object = (IProgramElement) iterator.next();
+                       if (object.getSourceLocation() != null && object.getSourceLocation().getLine() == line) {
+                               return object;
+                       }
+                       IProgramElement gotSomething = findElementAtLine(object, line);
+                       if (gotSomething != null) {
+                               return gotSomething;
+                       }
+               }
+               return null;
+       }
 }
\ No newline at end of file
index 2519577d4510a700fd828a2efc60464c40e34782..60cac88f378c7f78a1738e0f23383303f89e749c 100644 (file)
@@ -2,9 +2,22 @@
 
 <suite>
     
+    <ajc-test dir="bugs164/pr263666" title="around advice handles">
+      <compile files="x/A.java x/B.java x/OverrideOptions.aj" options="-1.5 -emacssym"/>
+    </ajc-test>
+    
+    
     <ajc-test dir="features164/aopconfig/one" title="aop config - 1">
       <compile files="A.java A2.java B.java foo.xml" options="-1.5 -showWeaveInfo">
-        <message kind="weave" text="goo"/>
+        <message kind="weave" text="Join point 'staticinitialization(void A.&lt;clinit&gt;())' in Type 'A' (A.java:1) advised by before advice from 'A' (A.java:2)"/>
+        <message kind="weave" text="Join point 'staticinitialization(void A2.&lt;clinit&gt;())' in Type 'A2' (A2.java:1) advised by before advice from 'A' (A.java:2)"/>
+        <message kind="weave" text="Join point 'staticinitialization(void B.&lt;clinit&gt;())' in Type 'B' (B.java:1) advised by before advice from 'A' (A.java:2)"/>
+      </compile>
+    </ajc-test>
+    
+    <ajc-test dir="features164/aopconfig/one" title="aop config - 2">
+      <compile files="A.java A2.java B.java B2.java foo2.xml" options="-1.5 -showWeaveInfo">
+        <message kind="weave" text="Join point 'staticinitialization(void B.&lt;clinit&gt;())' in Type 'B' (B.java:1) advised by before advice from 'A' (A.java:2)"/>
       </compile>
     </ajc-test>