aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs1920
diff options
context:
space:
mode:
authorAlexander Kriegisch <Alexander@Kriegisch.name>2023-08-15 08:58:14 +0700
committerAlexander Kriegisch <Alexander@Kriegisch.name>2023-08-15 08:58:14 +0700
commit565f37b1970268234d9a823e2631ba3ed3e03037 (patch)
treedc627f09995beee7932da7056a2be279294d9c0e /tests/bugs1920
parent364059c00f2393b8221cea29bdb6b7eabfd5b5c0 (diff)
downloadaspectj-565f37b1970268234d9a823e2631ba3ed3e03037.tar.gz
aspectj-565f37b1970268234d9a823e2631ba3ed3e03037.zip
Move 1.9.20 bug regression tests to the correct spots
Originally, I had intended to release a minor 1.9.19.1 release to fix some bugs. But then, Java 20 support was implemented and merged, so the next release will be 1.9.20. Therefore, I moved some bug regression tests to the 1.9.20 suite. Relates to #254. Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'tests/bugs1920')
-rw-r--r--tests/bugs1920/github_162/InterfaceWithInnerClass.java32
-rw-r--r--tests/bugs1920/github_190/SwitchCaseWith_Integer_MAX_VALUE.java20
-rw-r--r--tests/bugs1920/github_20/ParenthesisedAJKeywords.java33
-rw-r--r--tests/bugs1920/github_214/Application.java11
-rw-r--r--tests/bugs1920/github_214/FirstAspect.java11
-rw-r--r--tests/bugs1920/github_214/MarkerOne.java1
-rw-r--r--tests/bugs1920/github_214/MarkerTwo.java1
-rw-r--r--tests/bugs1920/github_214/SecondAspect.java12
-rw-r--r--tests/bugs1920/github_24/ExactlyMatchingAspect.aj25
-rw-r--r--tests/bugs1920/github_24/FuzzilyMatchingAspect.aj39
-rw-r--r--tests/bugs1920/github_24/MaybeMissingClass.java40
11 files changed, 225 insertions, 0 deletions
diff --git a/tests/bugs1920/github_162/InterfaceWithInnerClass.java b/tests/bugs1920/github_162/InterfaceWithInnerClass.java
new file mode 100644
index 000000000..f26975cc0
--- /dev/null
+++ b/tests/bugs1920/github_162/InterfaceWithInnerClass.java
@@ -0,0 +1,32 @@
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.JoinPoint;
+
+/**
+ * https://github.com/eclipse/org.aspectj/issues/162
+ */
+public interface InterfaceWithInnerClass {
+ public class ImplicitlyStatic {
+ public int getNumber() {
+ return 11;
+ }
+
+ public static void main(String[] args) {
+ System.out.println(new ImplicitlyStatic().getNumber());
+ }
+ }
+
+ /*static*/ aspect MyAspect {
+ before() : execution(* main(..)) {
+ System.out.println(thisJoinPoint);
+ }
+ }
+
+ @Aspect
+ /*static*/ class MyAnnotationAspect {
+ @Before("execution(* getNumber(..))")
+ public void myAdvice(JoinPoint thisJoinPoint){
+ System.out.println(thisJoinPoint);
+ }
+ }
+}
diff --git a/tests/bugs1920/github_190/SwitchCaseWith_Integer_MAX_VALUE.java b/tests/bugs1920/github_190/SwitchCaseWith_Integer_MAX_VALUE.java
new file mode 100644
index 000000000..d083fe60f
--- /dev/null
+++ b/tests/bugs1920/github_190/SwitchCaseWith_Integer_MAX_VALUE.java
@@ -0,0 +1,20 @@
+public class SwitchCaseWith_Integer_MAX_VALUE {
+ public static void main(String[] args) {
+ System.out.println(switchTest(Integer.MAX_VALUE));
+ }
+
+ static String switchTest(int i) {
+ switch (i) {
+ case Integer.MAX_VALUE:
+ return "CASE_1";
+ default:
+ return "";
+ }
+ }
+}
+
+aspect MyAspect {
+ before() : execution(* switchTest(*)) {
+ System.out.println(thisJoinPoint);
+ }
+}
diff --git a/tests/bugs1920/github_20/ParenthesisedAJKeywords.java b/tests/bugs1920/github_20/ParenthesisedAJKeywords.java
new file mode 100644
index 000000000..1ba013c57
--- /dev/null
+++ b/tests/bugs1920/github_20/ParenthesisedAJKeywords.java
@@ -0,0 +1,33 @@
+/**
+ * https://github.com/eclipse/org.aspectj/issues/20
+ */
+public class ParenthesisedAJKeywords {
+ public static void main(String[] args) {
+ boolean before = true;
+ int after = 11;
+ String around = "around";
+ boolean aspect = true;
+ int pointcut = 22;
+ String declare = "declare";
+ String privileged = "privileged";
+
+ if ((before)) {
+ System.out.println(foo((before)));
+ switch ((after)) {
+ default: System.out.println("after");
+ }
+ System.out.println((around));
+ System.out.println(!(aspect) ? "no aspect" : "aspect");
+ switch ((pointcut)) {
+ case 22: System.out.println("pointcut"); break;
+ default: System.out.println("xxx");
+ }
+ System.out.println((declare));
+ System.out.println((privileged));
+ }
+ }
+
+ public static String foo(boolean before) {
+ return (before) ? "before" : "after";
+ }
+}
diff --git a/tests/bugs1920/github_214/Application.java b/tests/bugs1920/github_214/Application.java
new file mode 100644
index 000000000..5401e0875
--- /dev/null
+++ b/tests/bugs1920/github_214/Application.java
@@ -0,0 +1,11 @@
+public class Application {
+ @MarkerTwo
+ @MarkerOne
+ public void greet(String name) {
+ System.out.println("Hello " + name + "!");
+ }
+
+ public static void main(String[] args) {
+ new Application().greet("world");
+ }
+}
diff --git a/tests/bugs1920/github_214/FirstAspect.java b/tests/bugs1920/github_214/FirstAspect.java
new file mode 100644
index 000000000..274e3a122
--- /dev/null
+++ b/tests/bugs1920/github_214/FirstAspect.java
@@ -0,0 +1,11 @@
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+
+@Aspect
+public class FirstAspect {
+ @Before("execution(@MarkerOne * *(..))")
+ public void beforeAdvice(JoinPoint joinPoint){
+ System.out.println("FirstAspect: " + joinPoint);
+ }
+}
diff --git a/tests/bugs1920/github_214/MarkerOne.java b/tests/bugs1920/github_214/MarkerOne.java
new file mode 100644
index 000000000..c59c42afc
--- /dev/null
+++ b/tests/bugs1920/github_214/MarkerOne.java
@@ -0,0 +1 @@
+public @interface MarkerOne { }
diff --git a/tests/bugs1920/github_214/MarkerTwo.java b/tests/bugs1920/github_214/MarkerTwo.java
new file mode 100644
index 000000000..213851d93
--- /dev/null
+++ b/tests/bugs1920/github_214/MarkerTwo.java
@@ -0,0 +1 @@
+public @interface MarkerTwo { }
diff --git a/tests/bugs1920/github_214/SecondAspect.java b/tests/bugs1920/github_214/SecondAspect.java
new file mode 100644
index 000000000..a4cc1bdb2
--- /dev/null
+++ b/tests/bugs1920/github_214/SecondAspect.java
@@ -0,0 +1,12 @@
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+
+@Aspect
+public class SecondAspect {
+ @Around("execution(@MarkerTwo * *(..))")
+ public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
+ System.out.println("SecondAspect: " + joinPoint);
+ return joinPoint.proceed();
+ }
+}
diff --git a/tests/bugs1920/github_24/ExactlyMatchingAspect.aj b/tests/bugs1920/github_24/ExactlyMatchingAspect.aj
new file mode 100644
index 000000000..a884d00fc
--- /dev/null
+++ b/tests/bugs1920/github_24/ExactlyMatchingAspect.aj
@@ -0,0 +1,25 @@
+public aspect ExactlyMatchingAspect {
+ after() : execution(public MaybeMissingClass MaybeMissingClass.*()) {
+ System.out.println(thisJoinPoint);
+ }
+
+ after() : execution(public MaybeMissingClass[] MaybeMissingClass.*()) {
+ System.out.println(thisJoinPoint);
+ }
+
+ after() : execution(public MaybeMissingClass[][] MaybeMissingClass.*()) {
+ System.out.println(thisJoinPoint);
+ }
+
+ after() : execution(public int MaybeMissingClass.*()) {
+ System.out.println(thisJoinPoint);
+ }
+
+ after() : execution(public int[] MaybeMissingClass.*()) {
+ System.out.println(thisJoinPoint);
+ }
+
+ after() : execution(public int[][] MaybeMissingClass.*()) {
+ System.out.println(thisJoinPoint);
+ }
+}
diff --git a/tests/bugs1920/github_24/FuzzilyMatchingAspect.aj b/tests/bugs1920/github_24/FuzzilyMatchingAspect.aj
new file mode 100644
index 000000000..b40c13c62
--- /dev/null
+++ b/tests/bugs1920/github_24/FuzzilyMatchingAspect.aj
@@ -0,0 +1,39 @@
+public aspect FuzzilyMatchingAspect {
+
+ pointcut returnRefTypeSimpleOrArray() : execution(public MaybeMissing* MaybeMissing*.*());
+ pointcut return1DimRefTypeArray() : execution(public MaybeMissing*[] MaybeMissing*.*());
+ pointcut return2DimRefTypeArray() : execution(public MaybeMissing*[][] MaybeMissing*.*());
+
+ // Return type 'MaybeMissing*' also matches array types due to the '*' at the end.
+ // Therefore, explicitly exclude array pointcuts in order to only match the method returning the simple type.
+ after() : returnRefTypeSimpleOrArray() && !return1DimRefTypeArray() && !return2DimRefTypeArray() {
+ System.out.println(thisJoinPoint);
+ }
+
+ after() : return1DimRefTypeArray() {
+ System.out.println(thisJoinPoint);
+ }
+
+ after() : return2DimRefTypeArray() {
+ System.out.println(thisJoinPoint);
+ }
+
+ pointcut returnPrimitiveTypeSimpleOrArray() : execution(public in* MaybeMissing*.*());
+ pointcut return1DimPrimitiveTypeArray() : execution(public in*[] MaybeMissing*.*());
+ pointcut return2DimPrimitiveTypeArray() : execution(public in*[][] MaybeMissing*.*());
+
+ // Return type 'in*' also matches array types due to the '*' at the end.
+ // Therefore, explicitly exclude array pointcuts in order to only match the method returning the simple type.
+ after() : returnPrimitiveTypeSimpleOrArray() && !return1DimPrimitiveTypeArray() && !return2DimPrimitiveTypeArray() {
+ System.out.println(thisJoinPoint);
+ }
+
+ after() : return1DimPrimitiveTypeArray() {
+ System.out.println(thisJoinPoint);
+ }
+
+ after() : return2DimPrimitiveTypeArray() {
+ System.out.println(thisJoinPoint);
+ }
+
+}
diff --git a/tests/bugs1920/github_24/MaybeMissingClass.java b/tests/bugs1920/github_24/MaybeMissingClass.java
new file mode 100644
index 000000000..17952583b
--- /dev/null
+++ b/tests/bugs1920/github_24/MaybeMissingClass.java
@@ -0,0 +1,40 @@
+public class MaybeMissingClass {
+ public static void main(String[] args) {
+ f1();
+ f2();
+ f3();
+ f4();
+ f5();
+ f6();
+ }
+
+ public static MaybeMissingClass f1() {
+ System.out.println("MaybeMissingClass.f1");
+ return null;
+ }
+
+ public static MaybeMissingClass[] f2() {
+ System.out.println("MaybeMissingClass.f2");
+ return null;
+ }
+
+ public static MaybeMissingClass[][] f3() {
+ System.out.println("MaybeMissingClass.f3");
+ return null;
+ }
+
+ public static int f4() {
+ System.out.println("MaybeMissingClass.f4");
+ return 0;
+ }
+
+ public static int[] f5() {
+ System.out.println("MaybeMissingClass.f5");
+ return new int[2];
+ }
+
+ public static int[][] f6() {
+ System.out.println("MaybeMissingClass.f6");
+ return new int[2][2];
+ }
+}