aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndy Clement <aclement@gopivotal.com>2014-08-27 13:25:21 -0700
committerAndy Clement <aclement@gopivotal.com>2014-08-27 13:25:21 -0700
commitd929114a6659d64d71c47f7bf8f70e9973e5c857 (patch)
tree9960a5e53a5b3cf697196191ded1fee9e55fa738 /tests
parent62b5e69a857ef64c71c39176d3fadc51c308ea02 (diff)
downloadaspectj-d929114a6659d64d71c47f7bf8f70e9973e5c857.tar.gz
aspectj-d929114a6659d64d71c47f7bf8f70e9973e5c857.zip
442425: fix error on attempted annotation style decp
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs183/442425/EntityController.java10
-rw-r--r--tests/bugs183/442425/EntityControllerAspect.java16
-rw-r--r--tests/bugs183/442425/EntityMongoController.java8
-rw-r--r--tests/bugs183/442425/IEntityController.java6
-rw-r--r--tests/bugs183/442425/MyAnnotatedController.java37
-rw-r--r--tests/bugs183/442425/de/scrum_master/app/EntityController.classbin0 -> 403 bytes
-rw-r--r--tests/bugs183/442425/de/scrum_master/app/EntityControllerAspect.classbin0 -> 1667 bytes
-rw-r--r--tests/bugs183/442425/de/scrum_master/app/EntityMongoController.classbin0 -> 996 bytes
-rw-r--r--tests/bugs183/442425/de/scrum_master/app/IEntityController.classbin0 -> 639 bytes
-rw-r--r--tests/bugs183/442425/de/scrum_master/app/MyAnnotatedController.classbin0 -> 3588 bytes
-rw-r--r--tests/src/org/aspectj/systemtest/ajc183/Ajc183Tests.java39
-rw-r--r--tests/src/org/aspectj/systemtest/ajc183/AllTestsAspectJ183.java27
-rw-r--r--tests/src/org/aspectj/systemtest/ajc183/ajc183.xml25
13 files changed, 168 insertions, 0 deletions
diff --git a/tests/bugs183/442425/EntityController.java b/tests/bugs183/442425/EntityController.java
new file mode 100644
index 000000000..2423b642d
--- /dev/null
+++ b/tests/bugs183/442425/EntityController.java
@@ -0,0 +1,10 @@
+package de.scrum_master.app;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface EntityController {}
diff --git a/tests/bugs183/442425/EntityControllerAspect.java b/tests/bugs183/442425/EntityControllerAspect.java
new file mode 100644
index 000000000..7540db933
--- /dev/null
+++ b/tests/bugs183/442425/EntityControllerAspect.java
@@ -0,0 +1,16 @@
+package de.scrum_master.app;
+
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.*;
+
+@Aspect
+public class EntityControllerAspect {
+ @DeclareParents(value = "@EntityController *", defaultImpl = EntityMongoController.class)
+ private IEntityController iEntityController;
+/*
+ @DeclareMixin("@EntityController *")
+ private IEntityController createEntityControllerInstance() {
+ return new EntityMongoController();
+ }
+*/
+}
diff --git a/tests/bugs183/442425/EntityMongoController.java b/tests/bugs183/442425/EntityMongoController.java
new file mode 100644
index 000000000..345f32043
--- /dev/null
+++ b/tests/bugs183/442425/EntityMongoController.java
@@ -0,0 +1,8 @@
+package de.scrum_master.app;
+
+public class EntityMongoController<T> implements IEntityController<T> {
+ private T entity;
+
+ public void setEntity(T entity) { this.entity = entity; }
+ public T getEntity() { return entity; }
+}
diff --git a/tests/bugs183/442425/IEntityController.java b/tests/bugs183/442425/IEntityController.java
new file mode 100644
index 000000000..440edcd31
--- /dev/null
+++ b/tests/bugs183/442425/IEntityController.java
@@ -0,0 +1,6 @@
+package de.scrum_master.app;
+
+public interface IEntityController<T> {
+ void setEntity(T entity);
+ T getEntity();
+}
diff --git a/tests/bugs183/442425/MyAnnotatedController.java b/tests/bugs183/442425/MyAnnotatedController.java
new file mode 100644
index 000000000..fab43b835
--- /dev/null
+++ b/tests/bugs183/442425/MyAnnotatedController.java
@@ -0,0 +1,37 @@
+package de.scrum_master.app;
+
+import java.lang.reflect.Method;
+
+@EntityController
+public class MyAnnotatedController<T> {
+ public void doSomething() {
+ System.out.println("Doing something");
+ }
+
+ public static void main(String[] args) {
+ // Use class type directly so as to call its method
+ MyAnnotatedController<String> annotatedTextController = new MyAnnotatedController<>();
+ annotatedTextController.doSomething();
+
+ // Print all declared methods (should also show interface methods introduced via ITD)
+ for (Method method : annotatedTextController.getClass().getDeclaredMethods()) {
+ if (!method.getName().startsWith("ajc$"))
+ System.out.println(method);
+ }
+
+ // Prove that class type is compatible with interface type
+ //IEntityController<String> entityTextController = annotatedTextController;
+ //entityTextController.setEntity("foo");
+ // Would not work here because generic interface type is type-safe:
+ // entityNumberController.setEntity(123);
+ //System.out.println("Entity value = " + entityTextController.getEntity());
+
+ // Create another object and directly assign it to interface type
+ //IEntityController<Integer> entityNumberController = new MyAnnotatedController<>();
+ //entityNumberController.setEntity(123);
+ // Would not work here because generic interface type is type-safe:
+ // entityNumberController.setEntity("foo");
+ //System.out.println("Entity value = " + entityNumberController.getEntity());
+ }
+}
+
diff --git a/tests/bugs183/442425/de/scrum_master/app/EntityController.class b/tests/bugs183/442425/de/scrum_master/app/EntityController.class
new file mode 100644
index 000000000..e224f8fea
--- /dev/null
+++ b/tests/bugs183/442425/de/scrum_master/app/EntityController.class
Binary files differ
diff --git a/tests/bugs183/442425/de/scrum_master/app/EntityControllerAspect.class b/tests/bugs183/442425/de/scrum_master/app/EntityControllerAspect.class
new file mode 100644
index 000000000..2e64a3da0
--- /dev/null
+++ b/tests/bugs183/442425/de/scrum_master/app/EntityControllerAspect.class
Binary files differ
diff --git a/tests/bugs183/442425/de/scrum_master/app/EntityMongoController.class b/tests/bugs183/442425/de/scrum_master/app/EntityMongoController.class
new file mode 100644
index 000000000..028780fb1
--- /dev/null
+++ b/tests/bugs183/442425/de/scrum_master/app/EntityMongoController.class
Binary files differ
diff --git a/tests/bugs183/442425/de/scrum_master/app/IEntityController.class b/tests/bugs183/442425/de/scrum_master/app/IEntityController.class
new file mode 100644
index 000000000..b3cd36beb
--- /dev/null
+++ b/tests/bugs183/442425/de/scrum_master/app/IEntityController.class
Binary files differ
diff --git a/tests/bugs183/442425/de/scrum_master/app/MyAnnotatedController.class b/tests/bugs183/442425/de/scrum_master/app/MyAnnotatedController.class
new file mode 100644
index 000000000..dae29b206
--- /dev/null
+++ b/tests/bugs183/442425/de/scrum_master/app/MyAnnotatedController.class
Binary files differ
diff --git a/tests/src/org/aspectj/systemtest/ajc183/Ajc183Tests.java b/tests/src/org/aspectj/systemtest/ajc183/Ajc183Tests.java
new file mode 100644
index 000000000..80541fc0f
--- /dev/null
+++ b/tests/src/org/aspectj/systemtest/ajc183/Ajc183Tests.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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.ajc183;
+
+import java.io.File;
+
+import junit.framework.Test;
+
+import org.aspectj.testing.XMLBasedAjcTestCase;
+
+/**
+ * @author Andy Clement
+ */
+public class Ajc183Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
+
+ public void testAnnoStyleDecp_442425() {
+ runTest("anno style decp");
+ }
+
+ // ---
+
+ public static Test suite() {
+ return XMLBasedAjcTestCase.loadSuite(Ajc183Tests.class);
+ }
+
+ @Override
+ protected File getSpecFile() {
+ return getClassResource("ajc183.xml");
+ }
+
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc183/AllTestsAspectJ183.java b/tests/src/org/aspectj/systemtest/ajc183/AllTestsAspectJ183.java
new file mode 100644
index 000000000..6caef2609
--- /dev/null
+++ b/tests/src/org/aspectj/systemtest/ajc183/AllTestsAspectJ183.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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.ajc183;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.aspectj.systemtest.apt.AptTests;
+
+public class AllTestsAspectJ183 {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("AspectJ 1.8.3 tests");
+ // $JUnit-BEGIN$
+ suite.addTest(Ajc183Tests.suite());
+ suite.addTest(AptTests.suite());
+ // $JUnit-END$
+ return suite;
+ }
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc183/ajc183.xml b/tests/src/org/aspectj/systemtest/ajc183/ajc183.xml
new file mode 100644
index 000000000..5a77148b7
--- /dev/null
+++ b/tests/src/org/aspectj/systemtest/ajc183/ajc183.xml
@@ -0,0 +1,25 @@
+<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]>
+
+<suite>
+
+ <ajc-test dir="bugs183/442425" title="anno style decp">
+ <compile options="-1.8" files="EntityController.java IEntityController.java MyAnnotatedController.java EntityControllerAspect.java EntityMongoController.java">
+ <message kind="error" line="23" text="Type mismatch: cannot convert from MyAnnotatedController&lt;String&gt; to IEntityController&lt;String&gt;"/>
+ <message kind="error" line="30" text="Cannot infer type arguments for MyAnnotatedController&lt;&gt;"/>
+ </compile>
+ <!--
+ <run class="de.scrum_master.app.MyAnnotatedController">
+ <stdout>
+ <line text="Doing something"/>
+ <line text="public static void de.scrum_master.app.MyAnnotatedController.main(java.lang.String[])"/>
+ <line text="public void de.scrum_master.app.MyAnnotatedController.doSomething()"/>
+ <line text="public java.lang.Object de.scrum_master.app.MyAnnotatedController.getEntity()"/>
+ <line text="public void de.scrum_master.app.MyAnnotatedController.setEntity(java.lang.Object)"/>
+ <line text="Entity value = foo"/>
+ <line text="Entity value = 123"/>
+ </stdout>
+ </run>
+ -->
+ </ajc-test>
+
+</suite>