]> source.dussan.org Git - aspectj.git/commitdiff
Add regression test for #250
authorAlexander Kriegisch <Alexander@Kriegisch.name>
Sat, 5 Aug 2023 04:34:59 +0000 (11:34 +0700)
committerAlexander Kriegisch <Alexander@Kriegisch.name>
Sun, 6 Aug 2023 02:38:11 +0000 (09:38 +0700)
Reproduces #250.

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
tests/bugs1920/github_250/MyAspect.aj [new file with mode: 0644]
tests/src/test/java/org/aspectj/systemtest/ajc1920/Bugs1920Tests.java
tests/src/test/resources/org/aspectj/systemtest/ajc1920/ajc1920.xml

diff --git a/tests/bugs1920/github_250/MyAspect.aj b/tests/bugs1920/github_250/MyAspect.aj
new file mode 100644 (file)
index 0000000..e832d0f
--- /dev/null
@@ -0,0 +1,40 @@
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+
+import java.util.Random;
+
+/**
+ * Reproduces <a href="https://github.com/eclipse-aspectj/aspectj/issues/250">Github bug 250</a>
+ */
+@Aspect
+public class MyAspect {
+  @Around("execution(* Application.*(..))")
+  public Object myAdvice1(ProceedingJoinPoint joinPoint) {
+    System.out.println(joinPoint);
+    a(1, "one");
+    return joinPoint.proceed();
+  }
+
+  @Around("execution(* Application.*(..))")
+  public Object myAdvice2(ProceedingJoinPoint joinPoint) throws Throwable {
+    System.out.println(joinPoint);
+    a(2);
+    return new Random().nextBoolean() ? joinPoint.proceed() : null;
+  }
+
+  private void a(int i) {
+    System.out.println(i);
+  }
+  private void a(int i, String s) {
+    System.out.println(i + " / " + s);
+  }
+
+  public static void main(String[] args) {
+    new Application().doSomething();
+  }
+}
+
+class Application {
+  public void doSomething() {}
+}
index 409a2e6751bb9d7495f8d3c4b9eb67f71d145ef6..593fdb1981d24ea6dfad16aa29c842c7ba6c2ace 100644 (file)
@@ -26,6 +26,15 @@ public class Bugs1920Tests extends XMLBasedAjcTestCase {
     runTest("add correct annotations to multiple ITD methods with the same name and same number of arguments");
   }
 
+  /**
+   * Make sure to create one {@code ajc$inlineAccessMethod} for identically named (overloaded) private aspect methods.
+   * <p>
+   * See <a href="https://github.com/eclipse-aspectj/aspectj/issues/250">GitHub issue 250</a>.
+   */
+  public void test_GitHub_250() {
+    runTest("correctly handle overloaded private methods in aspects");
+  }
+
   public static Test suite() {
     return XMLBasedAjcTestCase.loadSuite(Bugs1920Tests.class);
   }
index 9f072c86d304c66e9adb5573805cedd389da1d55..ed301b4f3412b5a053c46032017b033d18ef9fb7 100644 (file)
                </run>
        </ajc-test>
 
+       <!-- https://github.com/eclipse-aspectj/aspectj/issues/250 -->
+       <ajc-test dir="bugs1920/github_250" vm="8" title="correctly handle overloaded private methods in aspects">
+               <compile files="MyAspect.aj" options="-8"/>
+               <run class="MyAspect">
+                       <stdout>
+                               <line text="execution(void Application.doSomething())"/>
+                               <line text="1 / one"/>
+                               <line text="execution(void Application.doSomething())"/>
+                               <line text="2"/>
+                       </stdout>
+               </run>
+       </ajc-test>
+
 </suite>