aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndy Clement <aclement@pivotal.io>2019-01-17 12:20:57 -0800
committerAndy Clement <aclement@pivotal.io>2019-01-17 12:20:57 -0800
commit1a819be178964e0ec0c1caf5c515e3a9b9aa0df0 (patch)
treee8324e0c545f4bda6a0ced0c9a604886d416a0ee /tests
parent3abc52595deac0e9cd4a427a7eb6fe81170dc618 (diff)
downloadaspectj-1a819be178964e0ec0c1caf5c515e3a9b9aa0df0.tar.gz
aspectj-1a819be178964e0ec0c1caf5c515e3a9b9aa0df0.zip
Dig deeper to find WildTypePattern in DeclareParents
The existing check crudely only checked the top level, failing to find nested WildTypePatterns. Resolves #542682
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs193/542682/CaseA.java35
-rw-r--r--tests/bugs193/542682/EnumAspect04.aj12
-rw-r--r--tests/bugs193/542682/SimpleClass.java2
-rw-r--r--tests/bugs193/542682/SimpleEnum.java2
-rw-r--r--tests/bugs193/542682/SimpleEnum2.java2
-rw-r--r--tests/src/org/aspectj/systemtest/ajc193/Ajc193Tests.java18
-rw-r--r--tests/src/org/aspectj/systemtest/ajc193/ajc193.xml20
7 files changed, 84 insertions, 7 deletions
diff --git a/tests/bugs193/542682/CaseA.java b/tests/bugs193/542682/CaseA.java
new file mode 100644
index 000000000..f39609643
--- /dev/null
+++ b/tests/bugs193/542682/CaseA.java
@@ -0,0 +1,35 @@
+import java.lang.annotation.*;
+import org.aspectj.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface SomeAnnotation {}
+
+@SomeAnnotation
+public class CaseA {
+ public static void main(String[]argv) {
+ CaseA ca = new CaseA();
+ ((I)ca).methodOne(); // will only succeed if mixin applied
+ }
+}
+
+@SomeAnnotation
+enum Color {R,G,B}
+
+aspect X {
+ @DeclareMixin("(@SomeAnnotation *)")
+ public static I createImplementation() {
+ System.out.println("Delegate factory invoked");
+ return new Implementation();
+ }
+}
+
+interface I {
+ void methodOne();
+}
+
+class Implementation implements I {
+ public void methodOne() {
+ System.out.println("methodOne running");
+ }
+}
+
diff --git a/tests/bugs193/542682/EnumAspect04.aj b/tests/bugs193/542682/EnumAspect04.aj
new file mode 100644
index 000000000..41a34c2f1
--- /dev/null
+++ b/tests/bugs193/542682/EnumAspect04.aj
@@ -0,0 +1,12 @@
+import java.lang.annotation.*;
+import java.lang.Enum;
+
+public aspect EnumAspect04 {
+ interface I {};
+ //declare parents: SimpleE* implements I;
+ //declare parents: !*Aspect04 implements I;
+ declare parents: @Foo * implements I;
+}
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Foo {}
diff --git a/tests/bugs193/542682/SimpleClass.java b/tests/bugs193/542682/SimpleClass.java
new file mode 100644
index 000000000..ed1fe95fe
--- /dev/null
+++ b/tests/bugs193/542682/SimpleClass.java
@@ -0,0 +1,2 @@
+@Foo
+public class SimpleClass {}
diff --git a/tests/bugs193/542682/SimpleEnum.java b/tests/bugs193/542682/SimpleEnum.java
new file mode 100644
index 000000000..b5f5620f6
--- /dev/null
+++ b/tests/bugs193/542682/SimpleEnum.java
@@ -0,0 +1,2 @@
+@Foo
+public enum SimpleEnum { Red,Orange,Yellow,Green,Blue,Indigo,Violet };
diff --git a/tests/bugs193/542682/SimpleEnum2.java b/tests/bugs193/542682/SimpleEnum2.java
new file mode 100644
index 000000000..9aaf5a5f2
--- /dev/null
+++ b/tests/bugs193/542682/SimpleEnum2.java
@@ -0,0 +1,2 @@
+@Foo
+public enum SimpleEnum2 { Black, White };
diff --git a/tests/src/org/aspectj/systemtest/ajc193/Ajc193Tests.java b/tests/src/org/aspectj/systemtest/ajc193/Ajc193Tests.java
index c3849c4f0..255d7d871 100644
--- a/tests/src/org/aspectj/systemtest/ajc193/Ajc193Tests.java
+++ b/tests/src/org/aspectj/systemtest/ajc193/Ajc193Tests.java
@@ -1,12 +1,9 @@
/*******************************************************************************
- * Copyright (c) 2018 Contributors
+ * Copyright (c) 2018-2019 Contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andy Clement - initial API and implementation
*******************************************************************************/
package org.aspectj.systemtest.ajc193;
@@ -22,6 +19,15 @@ import junit.framework.Test;
*/
public class Ajc193Tests extends XMLBasedAjcTestCaseForJava10OrLater {
+ // Altered version of this test from org.aspectj.systemtest.ajc150.Enums for 542682
+ public void decpOnEnumNotAllowed_xlints() {
+ runTest("wildcard enum match in itd");
+ }
+
+ public void testEnumDecmixinMessage() {
+ runTest("declare mixin a");
+ }
+
public void testIsAbstractType() {
runTest("is abstract");
}
@@ -29,7 +35,7 @@ public class Ajc193Tests extends XMLBasedAjcTestCaseForJava10OrLater {
public void testIsAbstractType2() {
runTest("is abstract - 2");
}
-
+
// ---
public static Test suite() {
@@ -38,7 +44,7 @@ public class Ajc193Tests extends XMLBasedAjcTestCaseForJava10OrLater {
@Override
protected File getSpecFile() {
- return getClassResource("ajc193.xml");
+ return getClassResource("ajc193.xml");
}
}
diff --git a/tests/src/org/aspectj/systemtest/ajc193/ajc193.xml b/tests/src/org/aspectj/systemtest/ajc193/ajc193.xml
index 3f876abad..d5ed0f1c1 100644
--- a/tests/src/org/aspectj/systemtest/ajc193/ajc193.xml
+++ b/tests/src/org/aspectj/systemtest/ajc193/ajc193.xml
@@ -2,7 +2,25 @@
<suite>
-
+ <ajc-test dir="bugs193/542682" vm="1.5" title="wildcard enum match in itd">
+ <compile files="SimpleEnum.java,SimpleEnum2.java,EnumAspect04.aj" options="-1.5">
+ <message kind="warning" line="8" text="enum type SimpleEnum2 matches a declare parents type pattern but is being ignored"/>
+ <message kind="warning" line="8" text="enum type SimpleEnum matches a declare parents type pattern but is being ignored"/>
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="bugs193/542682" title="declare mixin a">
+ <compile files="CaseA.java" options="-1.8">
+ <message kind="warning" line="1" text="enum type Color matches a declare parents type pattern but is being ignored"/>
+ </compile>
+ <run class="CaseA">
+ <stdout>
+ <line text="Delegate factory invoked"/>
+ <line text="methodOne running"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
<ajc-test dir="bugs193/isAbstractType" title="is abstract">
<compile files="Code.java" options="-1.8"/>
<run class="Code">