]> source.dussan.org Git - aspectj.git/commitdiff
Add regression tests for GitHub bug #24
authorAlexander Kriegisch <Alexander@Kriegisch.name>
Sun, 8 Jan 2023 10:00:46 +0000 (11:00 +0100)
committerAlexander Kriegisch <Alexander@Kriegisch.name>
Sun, 15 Jan 2023 13:41:51 +0000 (14:41 +0100)
Relates to https://github.com/eclipse/org.aspectj/issues/24.

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
tests/bugs1919/github_24/ExactlyMatchingAspect.aj [new file with mode: 0644]
tests/bugs1919/github_24/FuzzilyMatchingAspect.aj [new file with mode: 0644]
tests/bugs1919/github_24/MaybeMissingClass.java [new file with mode: 0644]
tests/src/test/java/org/aspectj/systemtest/ajc1919/Bugs1919Tests.java
tests/src/test/resources/org/aspectj/systemtest/ajc1919/ajc1919.xml

diff --git a/tests/bugs1919/github_24/ExactlyMatchingAspect.aj b/tests/bugs1919/github_24/ExactlyMatchingAspect.aj
new file mode 100644 (file)
index 0000000..8a78394
--- /dev/null
@@ -0,0 +1,9 @@
+public aspect ExactlyMatchingAspect {
+  after() : execution(public MaybeMissingClass MaybeMissingClass.*()) {
+    System.out.println(thisJoinPoint);
+  }
+
+  after() : execution(public MaybeMissingClass[] MaybeMissingClass.*()) {
+    System.out.println(thisJoinPoint);
+  }
+}
diff --git a/tests/bugs1919/github_24/FuzzilyMatchingAspect.aj b/tests/bugs1919/github_24/FuzzilyMatchingAspect.aj
new file mode 100644 (file)
index 0000000..9992828
--- /dev/null
@@ -0,0 +1,9 @@
+public aspect FuzzilyMatchingAspect {
+  after() : execution(public MaybeMissing* MaybeMissing*.*()) {
+    System.out.println(thisJoinPoint);
+  }
+
+  after() : execution(public MaybeMissing*[] MaybeMissing*.*()) {
+    System.out.println(thisJoinPoint);
+  }
+}
diff --git a/tests/bugs1919/github_24/MaybeMissingClass.java b/tests/bugs1919/github_24/MaybeMissingClass.java
new file mode 100644 (file)
index 0000000..3fa5fa2
--- /dev/null
@@ -0,0 +1,16 @@
+public class MaybeMissingClass {
+  public static void main(String[] args) {
+    f1();
+    f2();
+  }
+
+  public static MaybeMissingClass f1() {
+    System.out.println("MaybeMissingClass.f1");
+    return null;
+  }
+
+  public static MaybeMissingClass[] f2() {
+    System.out.println("MaybeMissingClass.f2");
+    return null;
+  }
+}
index ae3c54398872086903df16584c4f37b37da19339..c20f9f2cf07fb31a5f10c0b04768449a30ba0011 100644 (file)
@@ -31,6 +31,22 @@ public class Bugs1919Tests extends XMLBasedAjcTestCase {
     runTest("inner aspect of interface is implicitly static");
   }
 
+  public void testExactArrayTypeMatchCompiledTogether() {
+    runTest("exact array type matching, aspect compiled together with target class");
+  }
+
+  public void testExactArrayTypeMatchCompiledSeparately() {
+    runTest("exact array type matching, aspect compiled separately from target class");
+  }
+
+  public void testFuzzyArrayTypeMatchCompiledTogether() {
+    runTest("fuzzy array type matching, aspect compiled together with target class");
+  }
+
+  public void testFuzzyArrayTypeMatchCompiledSeparately() {
+    runTest("fuzzy array type matching, aspect compiled separately from target class");
+  }
+
   public static Test suite() {
     return XMLBasedAjcTestCase.loadSuite(Bugs1919Tests.class);
   }
index f8945594178fe465b0a0ba9491854b1750798364..67c0b6328cc58b67dcb963cff9b17cd526d8d1a3 100644 (file)
                </run>
        </ajc-test>
 
+       <!--
+               When compiling aspect and target class together, matching works as expected,
+               see https://github.com/eclipse/org.aspectj/issues/24
+       -->
+       <ajc-test dir="bugs1919/github_24" vm="1.5" title="exact array type matching, aspect compiled together with target class">
+               <compile files="ExactlyMatchingAspect.aj MaybeMissingClass.java" options="-1.5 -showWeaveInfo">
+                       <!-- Even before the bugfix, in this case weaving worked as expected -->
+                       <message kind="weave" text="method-execution(MaybeMissingClass MaybeMissingClass.f1())'"/>
+                       <message kind="weave" text="method-execution(MaybeMissingClass[] MaybeMissingClass.f2())'"/>
+               </compile>
+               <run class="MaybeMissingClass">
+                       <stdout>
+                               <line text="MaybeMissingClass.f1"/>
+                               <line text="execution(MaybeMissingClass MaybeMissingClass.f1())"/>
+                               <line text="MaybeMissingClass.f2"/>
+                               <line text="execution(MaybeMissingClass[] MaybeMissingClass.f2())"/>
+                       </stdout>
+               </run>
+       </ajc-test>
+
+       <!--
+               When compiling aspect and target class separately, too many joinpoints are matched,
+               see https://github.com/eclipse/org.aspectj/issues/24
+       -->
+       <ajc-test dir="bugs1919/github_24" vm="1.5" title="exact array type matching, aspect compiled separately from target class">
+               <compile files="ExactlyMatchingAspect.aj" options="-1.5 -showWeaveInfo" outjar="aspect.jar">
+                       <message kind="warning" text="no match for this type name: MaybeMissingClass [Xlint:invalidAbsoluteTypeName]"/>
+                       <message kind="warning" text="no match for this type name: MaybeMissingClass [Xlint:invalidAbsoluteTypeName]"/>
+                       <message kind="warning" text="no match for this type name: MaybeMissingClass [Xlint:invalidAbsoluteTypeName]"/>
+                       <message kind="warning" text="no match for this type name: MaybeMissingClass [Xlint:invalidAbsoluteTypeName]"/>
+                       <message kind="warning" text="advice defined in ExactlyMatchingAspect has not been applied [Xlint:adviceDidNotMatch]"/>
+                       <message kind="warning" text="advice defined in ExactlyMatchingAspect has not been applied [Xlint:adviceDidNotMatch]"/>
+               </compile>
+               <compile files="MaybeMissingClass.java" options="-1.5 -showWeaveInfo" aspectpath="aspect.jar">
+                       <!-- Before the bugfix, f1 would be woven twice, f2 not at all-->
+                       <message kind="weave" text="method-execution(MaybeMissingClass MaybeMissingClass.f1())'"/>
+                       <message kind="weave" text="method-execution(MaybeMissingClass[] MaybeMissingClass.f2())'"/>
+               </compile>
+               <run class="MaybeMissingClass" classpath="aspect.jar">
+                       <stdout>
+                               <line text="MaybeMissingClass.f1"/>
+                               <line text="execution(MaybeMissingClass MaybeMissingClass.f1())"/>
+                               <line text="MaybeMissingClass.f2"/>
+                               <line text="execution(MaybeMissingClass[] MaybeMissingClass.f2())"/>
+                       </stdout>
+               </run>
+       </ajc-test>
+
+       <!--
+               When compiling aspect and target class together, too many joinpoints are matched,
+               see https://github.com/eclipse/org.aspectj/issues/24
+       -->
+       <ajc-test dir="bugs1919/github_24" vm="1.5" title="fuzzy array type matching, aspect compiled together with target class">
+               <compile files="FuzzilyMatchingAspect.aj MaybeMissingClass.java" options="-1.5 -showWeaveInfo">
+                       <!-- Before the bugfix, both f1 and f2 would be woven twice -->
+                       <message kind="weave" text="method-execution(MaybeMissingClass MaybeMissingClass.f1())'"/>
+                       <message kind="weave" text="method-execution(MaybeMissingClass[] MaybeMissingClass.f2())'"/>
+               </compile>
+               <run class="MaybeMissingClass">
+                       <stdout>
+                               <line text="MaybeMissingClass.f1"/>
+                               <line text="execution(MaybeMissingClass MaybeMissingClass.f1())"/>
+                               <line text="MaybeMissingClass.f2"/>
+                               <line text="execution(MaybeMissingClass[] MaybeMissingClass.f2())"/>
+                       </stdout>
+               </run>
+       </ajc-test>
+
+       <!--
+               When compiling aspect and target class separately, too many joinpoints are matched,
+               see https://github.com/eclipse/org.aspectj/issues/24
+       -->
+       <ajc-test dir="bugs1919/github_24" vm="1.5" title="fuzzy array type matching, aspect compiled separately from target class">
+               <compile files="FuzzilyMatchingAspect.aj" options="-1.5 -showWeaveInfo" outjar="aspect.jar">
+                       <message kind="warning" text="advice defined in FuzzilyMatchingAspect has not been applied [Xlint:adviceDidNotMatch]"/>
+                       <message kind="warning" text="advice defined in FuzzilyMatchingAspect has not been applied [Xlint:adviceDidNotMatch]"/>
+               </compile>
+               <compile files="MaybeMissingClass.java" options="-1.5 -showWeaveInfo" aspectpath="aspect.jar">
+                       <!-- Before the bugfix, both f1 and f2 would be woven twice -->
+                       <message kind="weave" text="method-execution(MaybeMissingClass MaybeMissingClass.f1())'"/>
+                       <message kind="weave" text="method-execution(MaybeMissingClass[] MaybeMissingClass.f2())'"/>
+               </compile>
+               <run class="MaybeMissingClass" classpath="aspect.jar">
+                       <stdout>
+                               <line text="MaybeMissingClass.f1"/>
+                               <line text="execution(MaybeMissingClass MaybeMissingClass.f1())"/>
+                               <line text="MaybeMissingClass.f2"/>
+                               <line text="execution(MaybeMissingClass[] MaybeMissingClass.f2())"/>
+                       </stdout>
+               </run>
+       </ajc-test>
+
 </suite>