aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/java5/ataspectj/annotationGen/ITDTest.aj181
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/ajc150.xml54
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjAnnotationGenTests.java4
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/ataspectj/annotationgen.xml8
4 files changed, 219 insertions, 28 deletions
diff --git a/tests/java5/ataspectj/annotationGen/ITDTest.aj b/tests/java5/ataspectj/annotationGen/ITDTest.aj
new file mode 100644
index 000000000..841af326b
--- /dev/null
+++ b/tests/java5/ataspectj/annotationGen/ITDTest.aj
@@ -0,0 +1,181 @@
+package a.b.c;
+
+import org.aspectj.lang.reflect.*;
+import java.lang.reflect.*;
+import org.aspectj.lang.annotation.*;
+
+public aspect ITDTest {
+
+ public void A.a(String s) {}
+
+ private void A.b(String s) {}
+
+ int A.c(String s) { return 1; }
+
+ public A.new(String s) {}
+
+ private A.new(String s,String s2) {}
+
+ A.new(String s, Object o) {}
+
+ public int A.f ;
+
+ private int A.g;
+
+ int A.h;
+
+ public static void main(String[] args) throws ClassNotFoundException {
+ AjType<ITDTest> myType = AjTypeSystem.getAjType(ITDTest.class);
+ checkITDMs(myType);
+ checkITDFs(myType);
+ checkITDCs(myType);
+ checkAnnStyle();
+ }
+
+ private static void checkITDMs(AjType<?> itdTest) throws ClassNotFoundException {
+ InterTypeMethodDeclaration[] itdms = itdTest.getDeclaredITDMethods();
+ assertEquals("expecting 3 declared methods, got: ",3,itdms.length);
+ assertEquals("expecting method name a, got: ","a",itdms[0].getName());
+ assertEquals("expecting method name b, got: ","b",itdms[1].getName());
+ assertEquals("expecting method name c, got: ","c",itdms[2].getName());
+ assertEquals("expecting AjType<a.b.c.A>",AjTypeSystem.getAjType(A.class),itdms[0].getTargetType());
+ assertEquals("expecting public method, got:",true,Modifier.isPublic(itdms[0].getModifiers()));
+ assertEquals("expecting private method, got:",true,Modifier.isPrivate(itdms[1].getModifiers()));
+ assertEquals("expecting non-public method, got:",false,Modifier.isPublic(itdms[2].getModifiers()));
+ assertEquals("one param, got: ",1,itdms[0].getParameterTypes().length);
+ assertEquals("expecting String, got: ",String.class,itdms[0].getParameterTypes()[0].getJavaClass());
+ assertEquals("nothing thrown, but: ",0,itdms[1].getExceptionTypes().length);
+ assertEquals("expecting int, got: ",int.class,itdms[2].getReturnType().getJavaClass());
+ itdms = itdTest.getITDMethods();
+ assertEquals("expecting 1 method, got: ",1,itdms.length);
+ assertEquals("expecting method name a, got: ","a",itdms[0].getName());
+ try {
+ InterTypeMethodDeclaration m = itdTest.getDeclaredITDMethod("b",AjTypeSystem.getAjType(A.class),AjTypeSystem.getAjType(String.class));
+ assertEquals("expecting b, got: ","b",m.getName());
+ } catch (NoSuchMethodException ex) { throw new RuntimeException("didn't find expected itdm"); }
+ try {
+ InterTypeMethodDeclaration m = itdTest.getITDMethod("d",AjTypeSystem.getAjType(A.class),AjTypeSystem.getAjType(String.class));
+ throw new RuntimeException("Expected NoSuchMethodException not thrown");
+ } catch (NoSuchMethodException ex) { }
+ }
+
+ private static void checkITDFs(AjType<?> itdTest) throws ClassNotFoundException {
+ InterTypeFieldDeclaration[] itdfs = itdTest.getDeclaredITDFields();
+ assertEquals("expecting 3 declared fields, got: ",3, itdfs.length);
+ assertEquals("expecting field name f, got: ","f",itdfs[0].getName());
+ assertEquals("expecting field name g, got: ","g",itdfs[1].getName());
+ assertEquals("expecting field name h, got: ","h",itdfs[2].getName());
+ assertEquals("expecting AjType<a.b.c.A>",AjTypeSystem.getAjType(A.class),itdfs[0].getTargetType());
+ assertEquals("expecting public field, got:",true,Modifier.isPublic(itdfs[0].getModifiers()));
+ assertEquals("expecting private field, got:",true,Modifier.isPrivate(itdfs[1].getModifiers()));
+ assertEquals("expecting non-public field, got:",false,Modifier.isPublic(itdfs[2].getModifiers()));
+ assertEquals("expecting int, got: ",int.class,itdfs[2].getType().getJavaClass());
+ itdfs = itdTest.getITDFields();
+ assertEquals("expecting 1 field, got: ",1, itdfs.length);
+ assertEquals("expecting field name f, got: ","f",itdfs[0].getName());
+ try {
+ InterTypeFieldDeclaration f = itdTest.getDeclaredITDField("f",AjTypeSystem.getAjType(A.class));
+ assertEquals("expecting f, got: ","f",f.getName());
+ } catch(NoSuchFieldException ex) { throw new RuntimeException("didn't find expected itdf"); }
+ try {
+ InterTypeFieldDeclaration g = itdTest.getITDField("g",AjTypeSystem.getAjType(A.class));
+ throw new RuntimeException("Expected NoSuchFieldException not thrown");
+ } catch (NoSuchFieldException ex) { }
+ }
+
+ private static void checkITDCs(AjType<?> itdTest) throws ClassNotFoundException {
+ InterTypeConstructorDeclaration[] itdcs = itdTest.getDeclaredITDConstructors();
+ assertEquals("expecting 3 declared constructors, got: ",3, itdcs.length);
+ InterTypeConstructorDeclaration pubDec = findPublicCons(itdcs);
+ InterTypeConstructorDeclaration privDec = findPrivateCons(itdcs);
+ InterTypeConstructorDeclaration defDec = findDefaultCons(itdcs);
+ if (pubDec == null || privDec == null || defDec == null) throw new RuntimeException("failed to find expected constructors");
+ assertEquals("two params, got: ",2,defDec.getParameterTypes().length);
+ assertEquals("expecting String, got: ",String.class,defDec.getParameterTypes()[0].getJavaClass());
+ assertEquals("expecting Object, got: ",Object.class,defDec.getParameterTypes()[1].getJavaClass());
+ assertEquals("nothing thrown, but: ",0,privDec.getExceptionTypes().length);
+ itdcs = itdTest.getITDConstructors();
+ assertEquals("expecting 1 cons, got: ",1,itdcs.length);
+ try {
+ InterTypeConstructorDeclaration c = itdTest.getDeclaredITDConstructor(AjTypeSystem.getAjType(A.class),AjTypeSystem.getAjType(String.class));
+ } catch (NoSuchMethodException ex) { throw new RuntimeException("didn't find expected itdm"); }
+ try {
+ InterTypeConstructorDeclaration c = itdTest.getITDConstructor(AjTypeSystem.getAjType(A.class),AjTypeSystem.getAjType(String.class),AjTypeSystem.getAjType(Object.class));
+ throw new RuntimeException("Expected NoSuchMethodException not thrown");
+ } catch (NoSuchMethodException ex) { }
+ }
+
+ private static InterTypeConstructorDeclaration findPublicCons(InterTypeConstructorDeclaration[] itcds) {
+ for( InterTypeConstructorDeclaration i : itcds) {
+ if (Modifier.isPublic(i.getModifiers())) {
+ return i;
+ }
+ }
+ return null;
+ }
+
+ private static InterTypeConstructorDeclaration findPrivateCons(InterTypeConstructorDeclaration[] itcds) {
+ for( InterTypeConstructorDeclaration i : itcds) {
+ if (Modifier.isPrivate(i.getModifiers())) {
+ return i;
+ }
+ }
+ return null;
+ }
+
+ private static InterTypeConstructorDeclaration findDefaultCons(InterTypeConstructorDeclaration[] itcds) {
+ for( InterTypeConstructorDeclaration i : itcds) {
+ if (!Modifier.isPublic(i.getModifiers()) && !Modifier.isPrivate(i.getModifiers())) {
+ return i;
+ }
+ }
+ return null;
+ }
+
+ private static void checkAnnStyle() {
+ AjType<X> x = AjTypeSystem.getAjType(X.class);
+ org.aspectj.lang.reflect.DeclareParents[] decps = x.getDeclareParents();
+ assertEquals("1 declare parents",1,decps.length);
+ assertEquals("implements",true,decps[0].isImplements());
+ assertEquals("X",x,decps[0].getDeclaringType());
+ assertEquals("org.xyz..*, got: ","org.xyz..*",decps[0].getTargetTypesPattern().asString());
+ try {
+ assertEquals("1: ",1,decps[0].getParentTypes().length);
+ assertEquals("I: ",I.class,((AjType<?>)decps[0].getParentTypes()[0]).getJavaClass());
+ } catch (ClassNotFoundException cnf) {
+ throw new RuntimeException(cnf);
+ }
+ assertEquals("1: ",1,x.getDeclaredITDFields().length);
+ assertEquals("i: ","i",x.getDeclaredITDFields()[0].getName());
+ assertEquals("1: ",1,x.getITDMethods().length);
+ assertEquals("getNumber: ","getNumber",x.getITDMethods()[0].getName());
+ }
+
+ private static void assertEquals(String msg, Object expected, Object actual) {
+ if (!expected.equals(actual)) throw new RuntimeException(msg + " " + actual.toString());
+ }
+}
+
+
+class A {}
+
+@Aspect
+class X {
+
+ @org.aspectj.lang.annotation.DeclareParents("org.xyz..*")
+ public static class Mixin implements I {
+
+ private int i = 0;
+
+ public int getNumber() { return i; }
+
+ }
+
+}
+
+interface I {
+
+ int getNumber();
+
+}
+
diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
index ef3f9fcd4..3c0335717 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
+++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
@@ -4586,7 +4586,7 @@
<!-- ============================================================== -->
<ajc-test dir="bugs150/pr98901" title="public method with declare @method">
- <compile files="Case01.aj" options="-1.5 -Xlint:error"/>
+ <compile files="Case01.aj" options="-1.5 -Xlint:error -Xdev:NoAtAspectJProcessing"/>
<run class="B01">
<stdout>
<line text="@anInterface()"/>
@@ -4617,7 +4617,7 @@
</ajc-test>
<ajc-test dir="bugs150/pr98901" title="public ITD method with declare @method">
- <compile files="Case04.aj" options="-1.5 -Xlint:error"/>
+ <compile files="Case04.aj" options="-1.5 -Xlint:error -Xdev:NoAtAspectJProcessing"/>
<run class="B04">
<stdout>
<line text="@anInterface()"/>
@@ -4626,7 +4626,7 @@
</ajc-test>
<ajc-test dir="bugs150/pr98901" title="public annotated ITD method">
- <compile files="Case05.aj" options="-1.5 -Xlint:error"/>
+ <compile files="Case05.aj" options="-1.5 -Xlint:error -Xdev:NoAtAspectJProcessing"/>
<run class="B05">
<stdout>
<line text="@anInterface()"/>
@@ -4635,7 +4635,7 @@
</ajc-test>
<ajc-test dir="bugs150/pr98901" title="public ITD-on-itself method with declare @method">
- <compile files="Case06.aj" options="-1.5 -Xlint:error"/>
+ <compile files="Case06.aj" options="-1.5 -Xlint:error -Xdev:NoAtAspectJProcessing"/>
<run class="B06">
<stdout>
<line text="@anInterface()"/>
@@ -4644,7 +4644,7 @@
</ajc-test>
<ajc-test dir="bugs150/pr98901" title="public annotated ITD-on-itself method">
- <compile files="Case07.aj" options="-1.5 -Xlint:error"/>
+ <compile files="Case07.aj" options="-1.5 -Xlint:error -Xdev:NoAtAspectJProcessing"/>
<run class="B07">
<stdout>
<line text="@anInterface()"/>
@@ -4653,7 +4653,7 @@
</ajc-test>
<ajc-test dir="bugs150/pr98901" title="public method on an Interface with declare @method">
- <compile files="Case08.aj" options="-1.5 -Xlint:error"/>
+ <compile files="Case08.aj" options="-1.5 -Xlint:error -Xdev:NoAtAspectJProcessing"/>
<run class="B08">
<stdout>
<line text="@anInterface()"/>
@@ -4662,7 +4662,7 @@
</ajc-test>
<ajc-test dir="bugs150/pr98901" title="public annotated method on an Interface">
- <compile files="Case09.aj" options="-1.5 -Xlint:error"/>
+ <compile files="Case09.aj" options="-1.5 -Xlint:error -Xdev:NoAtAspectJProcessing"/>
<run class="B09">
<stdout>
<line text="@anInterface()"/>
@@ -4671,7 +4671,7 @@
</ajc-test>
<ajc-test dir="bugs150/pr98901" title="public ITD method onto an Interface with declare @method">
- <compile files="Case10.aj" options="-1.5 -Xlint:error"/>
+ <compile files="Case10.aj" options="-1.5 -Xlint:error -Xdev:NoAtAspectJProcessing"/>
<run class="B10">
<stdout>
<line text="@anInterface()"/>
@@ -4680,7 +4680,7 @@
</ajc-test>
<ajc-test dir="bugs150/pr98901" title="public annotated ITD method onto an Interface">
- <compile files="Case11.aj" options="-1.5 -Xlint:error"/>
+ <compile files="Case11.aj" options="-1.5 -Xlint:error -Xdev:NoAtAspectJProcessing"/>
<run class="B11">
<stdout>
<line text="@anInterface()"/>
@@ -4689,7 +4689,7 @@
</ajc-test>
<ajc-test dir="bugs150/pr98901" title="public abstract method with declare @method">
- <compile files="Case12.aj" options="-1.5 -Xlint:error"/>
+ <compile files="Case12.aj" options="-1.5 -Xlint:error -Xdev:NoAtAspectJProcessing"/>
<run class="B12">
<stdout>
<line text="@anInterface()"/>
@@ -4698,7 +4698,7 @@
</ajc-test>
<ajc-test dir="bugs150/pr98901" title="public abstract method on the aspect that declares @method on it">
- <compile files="Case13.aj" options="-1.5 -Xlint:error"/>
+ <compile files="Case13.aj" options="-1.5 -Xlint:error -Xdev:NoAtAspectJProcessing"/>
<run class="B13">
<stdout>
<line text="@anInterface()"/>
@@ -4707,7 +4707,7 @@
</ajc-test>
<ajc-test dir="bugs150/pr98901" title="public abstract annotated method">
- <compile files="Case14.aj" options="-1.5 -Xlint:error"/>
+ <compile files="Case14.aj" options="-1.5 -Xlint:error -Xdev:NoAtAspectJProcessing"/>
<run class="B14">
<stdout>
<line text="@anInterface()"/>
@@ -4716,7 +4716,7 @@
</ajc-test>
<ajc-test dir="bugs150/pr98901" title="public abstract ITD method with declare @method">
- <compile files="Case15.aj" options="-1.5 -Xlint:error"/>
+ <compile files="Case15.aj" options="-1.5 -Xlint:error -Xdev:NoAtAspectJProcessing"/>
<run class="B15">
<stdout>
<line text="@anInterface()"/>
@@ -4725,7 +4725,7 @@
</ajc-test>
<ajc-test dir="bugs150/pr98901" title="public abstract annotated ITD method">
- <compile files="Case16.aj" options="-1.5 -Xlint:error"/>
+ <compile files="Case16.aj" options="-1.5 -Xlint:error -Xdev:NoAtAspectJProcessing"/>
<run class="B16">
<stdout>
<line text="@anInterface()"/>
@@ -4734,7 +4734,7 @@
</ajc-test>
<ajc-test dir="bugs150/pr98901" title="public abstract ITD-on-itself method with declare @method">
- <compile files="Case17.aj" options="-1.5 -Xlint:error"/>
+ <compile files="Case17.aj" options="-1.5 -Xlint:error -Xdev:NoAtAspectJProcessing"/>
<run class="B17">
<stdout>
<line text="@anInterface()"/>
@@ -4743,7 +4743,7 @@
</ajc-test>
<ajc-test dir="bugs150/pr98901" title="public abstract annotated ITD-on-itself method">
- <compile files="Case18.aj" options="-1.5 -Xlint:error"/>
+ <compile files="Case18.aj" options="-1.5 -Xlint:error -Xdev:NoAtAspectJProcessing"/>
<run class="B18">
<stdout>
<line text="@anInterface()"/>
@@ -4752,7 +4752,7 @@
</ajc-test>
<ajc-test dir="bugs150/pr98901" title="public abstract method on an Interface with declare @method">
- <compile files="Case19.aj" options="-1.5 -Xlint:error"/>
+ <compile files="Case19.aj" options="-1.5 -Xlint:error -Xdev:NoAtAspectJProcessing"/>
<run class="B19">
<stdout>
<line text="@anInterface()"/>
@@ -4761,7 +4761,7 @@
</ajc-test>
<ajc-test dir="bugs150/pr98901" title="public abstract annotated method on an Interface">
- <compile files="Case20.aj" options="-1.5 -Xlint:error"/>
+ <compile files="Case20.aj" options="-1.5 -Xlint:error -Xdev:NoAtAspectJProcessing"/>
<run class="B20">
<stdout>
<line text="@anInterface()"/>
@@ -4770,7 +4770,7 @@
</ajc-test>
<ajc-test dir="bugs150/pr98901" title="public abstract ITD method onto an Interface with declare @method">
- <compile files="Case21.aj" options="-1.5 -Xlint:error"/>
+ <compile files="Case21.aj" options="-1.5 -Xlint:error -Xdev:NoAtAspectJProcessing"/>
<run class="B21">
<stdout>
<line text="@anInterface()"/>
@@ -4779,7 +4779,7 @@
</ajc-test>
<ajc-test dir="bugs150/pr98901" title="public abstract annotated ITD method onto an Interface">
- <compile files="Case22.aj" options="-1.5 -Xlint:error"/>
+ <compile files="Case22.aj" options="-1.5 -Xlint:error -Xdev:NoAtAspectJProcessing"/>
<run class="B22">
<stdout>
<line text="@anInterface()"/>
@@ -4788,7 +4788,7 @@
</ajc-test>
<ajc-test dir="bugs150/pr98901" title="public field with declare @field">
- <compile files="Case23.aj" options="-1.5 -Xlint:error"/>
+ <compile files="Case23.aj" options="-1.5 -Xlint:error -Xdev:NoAtAspectJProcessing"/>
<run class="B23">
<stdout>
<line text="@anInterface()"/>
@@ -4798,7 +4798,7 @@
<ajc-test dir="bugs150/pr98901" title="public field on the aspect that declares @field on it">
- <compile files="Case24.aj" options="-1.5 -Xlint:error"/>
+ <compile files="Case24.aj" options="-1.5 -Xlint:error -Xdev:NoAtAspectJProcessing"/>
<run class="B24">
<stdout>
<line text="@anInterface()"/>
@@ -4807,7 +4807,7 @@
</ajc-test>
<ajc-test dir="bugs150/pr98901" title="public annotated field">
- <compile files="Case25.aj" options="-1.5 -Xlint:error"/>
+ <compile files="Case25.aj" options="-1.5 -Xlint:error -Xdev:NoAtAspectJProcessing"/>
<run class="B25">
<stdout>
<line text="@anInterface()"/>
@@ -4816,7 +4816,7 @@
</ajc-test>
<ajc-test dir="bugs150/pr98901" title="public ITD field with declare @field">
- <compile files="Case26.aj" options="-1.5 -Xlint:error"/>
+ <compile files="Case26.aj" options="-1.5 -Xlint:error -Xdev:NoAtAspectJProcessing"/>
<run class="B26">
<stdout>
<line text="@anInterface()"/>
@@ -4825,7 +4825,7 @@
</ajc-test>
<ajc-test dir="bugs150/pr98901" title="public annotated ITD field">
- <compile files="Case27.aj" options="-1.5 -Xlint:error"/>
+ <compile files="Case27.aj" options="-1.5 -Xlint:error -Xdev:NoAtAspectJProcessing"/>
<run class="B27">
<stdout>
<line text="@anInterface()"/>
@@ -4834,7 +4834,7 @@
</ajc-test>
<ajc-test dir="bugs150/pr98901" title="public ITD-on-itself field with declare @field">
- <compile files="Case28.aj" options="-1.5 -Xlint:error"/>
+ <compile files="Case28.aj" options="-1.5 -Xlint:error -Xdev:NoAtAspectJProcessing"/>
<run class="B28">
<stdout>
<line text="@anInterface()"/>
@@ -4843,7 +4843,7 @@
</ajc-test>
<ajc-test dir="bugs150/pr98901" title="public annotated ITD-on-itself field">
- <compile files="Case29.aj" options="-1.5 -Xlint:error"/>
+ <compile files="Case29.aj" options="-1.5 -Xlint:error -Xdev:NoAtAspectJProcessing"/>
<run class="B29">
<stdout>
<line text="@anInterface()"/>
diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjAnnotationGenTests.java b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjAnnotationGenTests.java
index c3711841f..27b562d62 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjAnnotationGenTests.java
+++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjAnnotationGenTests.java
@@ -150,5 +150,9 @@ public class AtAjAnnotationGenTests extends XMLBasedAjcTestCase {
public void testDecAnnotation() {
runTest("ann gen for dec annotation");
}
+
+ public void testITDs() {
+ runTest("ann gen for itds");
+ }
}
diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/annotationgen.xml b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/annotationgen.xml
index 3e74a541a..33c28dbb3 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/annotationgen.xml
+++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/annotationgen.xml
@@ -177,5 +177,11 @@
<compile files="DeclareAnnotationTest.aj" options="-1.5">
</compile>
<run class="DeclareAnnotationTest"/>
- </ajc-test>
+ </ajc-test>
+
+ <ajc-test dir="java5/ataspectj/annotationGen" title="ann gen for itds">
+ <compile files="ITDTest.aj" options="-1.5">
+ </compile>
+ <run class="a.b.c.ITDTest"/>
+ </ajc-test>
</suite> \ No newline at end of file