From 8170ae6ffd7068a3f224de0df2008d74d6b9d35b Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Sat, 5 Aug 2023 11:34:59 +0700 Subject: [PATCH] Add regression test for #250 Reproduces #250. Signed-off-by: Alexander Kriegisch --- tests/bugs1920/github_250/MyAspect.aj | 40 +++++++++++++++++++ .../systemtest/ajc1920/Bugs1920Tests.java | 9 +++++ .../aspectj/systemtest/ajc1920/ajc1920.xml | 13 ++++++ 3 files changed, 62 insertions(+) create mode 100644 tests/bugs1920/github_250/MyAspect.aj diff --git a/tests/bugs1920/github_250/MyAspect.aj b/tests/bugs1920/github_250/MyAspect.aj new file mode 100644 index 000000000..e832d0f68 --- /dev/null +++ b/tests/bugs1920/github_250/MyAspect.aj @@ -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 Github bug 250 + */ +@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() {} +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1920/Bugs1920Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc1920/Bugs1920Tests.java index 409a2e675..593fdb198 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc1920/Bugs1920Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1920/Bugs1920Tests.java @@ -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. + *

+ * See GitHub issue 250. + */ + public void test_GitHub_250() { + runTest("correctly handle overloaded private methods in aspects"); + } + public static Test suite() { return XMLBasedAjcTestCase.loadSuite(Bugs1920Tests.class); } diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc1920/ajc1920.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc1920/ajc1920.xml index 9f072c86d..ed301b4f3 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc1920/ajc1920.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc1920/ajc1920.xml @@ -190,4 +190,17 @@ + + + + + + + + + + + + + -- 2.39.5