]> source.dussan.org Git - aspectj.git/commitdiff
286473: tests
authoraclement <aclement>
Wed, 23 Sep 2009 21:00:59 +0000 (21:00 +0000)
committeraclement <aclement>
Wed, 23 Sep 2009 21:00:59 +0000 (21:00 +0000)
tests/bugs166/pr286473/Anno.java [new file with mode: 0644]
tests/bugs166/pr286473/Bottom.java [new file with mode: 0644]
tests/bugs166/pr286473/LTWTest.java [new file with mode: 0644]
tests/bugs166/pr286473/Mark.java [new file with mode: 0644]
tests/bugs166/pr286473/Middle.java [new file with mode: 0644]
tests/bugs166/pr286473/Top.java [new file with mode: 0644]
tests/bugs166/pr286473/aop.xml [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc166/Ajc166Tests.java
tests/src/org/aspectj/systemtest/ajc166/ajc166.xml

diff --git a/tests/bugs166/pr286473/Anno.java b/tests/bugs166/pr286473/Anno.java
new file mode 100644 (file)
index 0000000..d7fce2e
--- /dev/null
@@ -0,0 +1,11 @@
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface Anno {
+
+}
diff --git a/tests/bugs166/pr286473/Bottom.java b/tests/bugs166/pr286473/Bottom.java
new file mode 100644 (file)
index 0000000..531cf41
--- /dev/null
@@ -0,0 +1,5 @@
+
+@Anno
+public class Bottom extends Middle {
+  public void bottom() {}
+}
diff --git a/tests/bugs166/pr286473/LTWTest.java b/tests/bugs166/pr286473/LTWTest.java
new file mode 100644 (file)
index 0000000..59b596f
--- /dev/null
@@ -0,0 +1,56 @@
+
+import java.lang.reflect.Method;
+import java.util.*;
+
+public class LTWTest {
+
+       public void noDoubles() throws Exception {
+               Method[] methods = Bottom.class.getMethods();
+               System.out.println("Bottom.getMethods()");
+                boolean broken = false;
+                List<String> l = new ArrayList<String>();
+               for (Method method : methods) {
+                       if (!method.getDeclaringClass().equals(Object.class)) {
+                         l.add(method.getName() + " : " + method.getDeclaringClass().getName());
+                        }
+                       if (method.getDeclaringClass().equals(Bottom.class)) {
+                          if (method.getName().equals("markMethod"))  {
+                            broken=true;
+                          }
+                       }
+               }
+               Collections.sort(l);
+                for (String s: l) {
+                  System.out.println(s);
+                }
+                if (broken) {
+                  throw new IllegalStateException("Bottom.getMethods() should not include a markMethod() declared by Bottom");
+                }
+       }       
+       
+       public void grandChildInherits() throws Exception {
+               Method[] methods = Bottom.class.getDeclaredMethods();
+               for (Method method : methods) {
+      if (method.getName().equals("markMethod")) 
+throw new RuntimeException();
+//                     assertThat(method.getName(), not(equalTo("doSomething")));
+               }
+               
+/*
+               methods = Bottom.class.getMethods();
+               for (Method method : methods) {
+                       if (method.getName().equals("doSomething")) {
+                               System.out.println(method.getDeclaringClass().getName());
+                       }
+               }
+*/
+               
+       }
+       
+       public static void main(String[] args) throws Exception {
+               LTWTest t = new LTWTest();
+               t.noDoubles();
+               t.grandChildInherits();
+       }
+       
+}
diff --git a/tests/bugs166/pr286473/Mark.java b/tests/bugs166/pr286473/Mark.java
new file mode 100644 (file)
index 0000000..cbe018a
--- /dev/null
@@ -0,0 +1,13 @@
+public aspect Mark {
+
+       public static interface IMarker {
+               
+       }
+       
+       public String IMarker.markMethod() {
+               return "something done";
+       }
+       
+       declare parents : ((@Anno *)) implements IMarker;
+       
+}
diff --git a/tests/bugs166/pr286473/Middle.java b/tests/bugs166/pr286473/Middle.java
new file mode 100644 (file)
index 0000000..7dddb06
--- /dev/null
@@ -0,0 +1,5 @@
+
+@Anno
+public class Middle extends Top {
+  public void middle() {}
+}
diff --git a/tests/bugs166/pr286473/Top.java b/tests/bugs166/pr286473/Top.java
new file mode 100644 (file)
index 0000000..f383600
--- /dev/null
@@ -0,0 +1,5 @@
+
+@Anno
+public class Top {
+
+}
diff --git a/tests/bugs166/pr286473/aop.xml b/tests/bugs166/pr286473/aop.xml
new file mode 100644 (file)
index 0000000..31fb5fe
--- /dev/null
@@ -0,0 +1,6 @@
+<aspectj>
+ <aspects>
+  <aspect name="Mark"/>
+ </aspects>
+ <weaver options="-showWeaveInfo -Xset:completeBinaryTypes=true"/>
+</aspectj>
index 714e81facba7f8067de4a7bb70e5a19e2e1d3568..59265110e20cb7e8ab0ed8bef348c84c148e208b 100644 (file)
@@ -18,6 +18,14 @@ import org.aspectj.testing.XMLBasedAjcTestCase;
 
 public class Ajc166Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
 
+       public void testParentsLTW_286473_binary() {
+               runTest("parents ltw - binary");
+       }
+
+       public void testParentsLTW_286473_ltw() {
+               runTest("parents ltw - ltw");
+       }
+
        public void testNpeForJavacBuilt_290227() {
                runTest("npe for javac built");
        }
index 991cfdb68f72d20630a3062c9b462e720e5ea036..d19a3b4850b4f3754116e0ed27fc2ef47bc572d5 100644 (file)
@@ -2,6 +2,51 @@
 
 <suite>
 
+  <ajc-test dir="bugs166/pr286473" title="parents ltw - binary">
+    <compile files="Anno.java Top.java Middle.java Bottom.java" outjar="code.jar" options="-1.5 -Xlint:ignore"/>
+    <compile files="Mark.java LTWTest.java" inpath="code.jar" options="-1.5 -showWeaveInfo">
+       <message kind="weave" text="Type 'Mark$IMarker' (Mark.java) has intertyped method from 'Mark' (Mark.java:'java.lang.String Mark$IMarker.markMethod()')"/>
+               <message kind="weave" text="Extending interface set for type 'Top' (Top.java) to include 'Mark$IMarker' (Mark.java)"/>
+               <message kind="weave" text="Type 'Top' (Top.java) has intertyped method from 'Mark' (Mark.java:'java.lang.String Mark$IMarker.markMethod()')"/>
+    </compile>
+    <run class="LTWTest">
+      <stdout>
+        <line text="Bottom.getMethods()"/>
+        <line text="bottom : Bottom"/>
+        <line text="markMethod : Top"/>
+        <line text="middle : Middle"/>
+      </stdout>
+    </run>
+  </ajc-test>
+  
+  <ajc-test dir="bugs166/pr286473" title="parents ltw - ltw">
+    <compile files="Anno.java Top.java Middle.java Bottom.java" outjar="code.jar" options="-1.5 -Xlint:ignore"/>
+    <compile files="Mark.java LTWTest.java" classpath="code.jar" options="-1.5">
+    </compile>
+    <run class="LTWTest" ltw="aop.xml">
+      <stderr>
+        <line text="Extending interface set for type 'Top' (Top.java) to include 'Mark$IMarker' (Mark.java)"/>
+        <line text="Type 'Top' (Top.java) has intertyped method from 'Mark' (Mark.java:'java.lang.String Mark$IMarker.markMethod()')"/>
+        <line text="Type 'Mark$IMarker' (Mark.java) has intertyped method from 'Mark' (Mark.java:'java.lang.String Mark$IMarker.markMethod()')"/>
+<!--
+        <line text="Extending interface set for type 'Bottom' (Bottom.java) to include 'Mark$IMarker' (Mark.java)"/>
+        <line text="Type 'Bottom' (Bottom.java) has intertyped method from 'Mark' (Mark.java:'java.lang.String Mark$IMarker.markMethod()')"/>
+        <line text="Type 'Mark$IMarker' (Mark.java) has intertyped method from 'Mark' (Mark.java:'java.lang.String Mark$IMarker.markMethod()')"/>
+        <line text="Extending interface set for type 'Middle' (Middle.java) to include 'Mark$IMarker' (Mark.java)"/>
+        <line text="Type 'Middle' (Middle.java) has intertyped method from 'Mark' (Mark.java:'java.lang.String Mark$IMarker.markMethod()')"/>
+        <line text="Extending interface set for type 'Top' (Top.java) to include 'Mark$IMarker' (Mark.java)"/>
+        <line text="Type 'Top' (Top.java) has intertyped method from 'Mark' (Mark.java:'java.lang.String Mark$IMarker.markMethod()')"/>
+        -->
+      </stderr>
+      <stdout>
+        <line text="Bottom.getMethods()"/>
+        <line text="bottom : Bottom"/>
+        <line text="markMethod : Top"/>
+        <line text="middle : Middle"/>
+      </stdout>
+    </run>
+  </ajc-test>
+
   <ajc-test dir="bugs166/pr290227" title="npe for javac built">
     <compile files="" inpath="javacCode.jar" options="-1.5 -Xlint:ignore"/>
   </ajc-test>