diff options
author | aclement <aclement> | 2005-08-22 17:00:01 +0000 |
---|---|---|
committer | aclement <aclement> | 2005-08-22 17:00:01 +0000 |
commit | 1abe388fddf09811e19dbb1405ed8d81c0cec694 (patch) | |
tree | 370ef5cb166a1e22a2755020e104b4d6d95c3984 | |
parent | ffec34a47eb415e55b132be4f73d73c9ae4aadd5 (diff) | |
download | aspectj-1abe388fddf09811e19dbb1405ed8d81c0cec694.tar.gz aspectj-1abe388fddf09811e19dbb1405ed8d81c0cec694.zip |
genericitds: tests moved around and activated in GenericsTests
22 files changed, 504 insertions, 207 deletions
diff --git a/tests/java5/generics/binaryweaving/A1.aj b/tests/java5/generics/binaryweaving/A1.aj new file mode 100644 index 000000000..45f7fe779 --- /dev/null +++ b/tests/java5/generics/binaryweaving/A1.aj @@ -0,0 +1,5 @@ +aspect A1 { + declare parents: C* implements I<String>; +} + +interface I<T> {} diff --git a/tests/java5/generics/binaryweaving/C1.aj b/tests/java5/generics/binaryweaving/C1.aj new file mode 100644 index 000000000..b76d06a3c --- /dev/null +++ b/tests/java5/generics/binaryweaving/C1.aj @@ -0,0 +1 @@ +class C1 {} diff --git a/tests/java5/generics/genericaspects/GenericAspectT.aj b/tests/java5/generics/genericaspects/GenericAspectT.aj index a34e4c0b4..8efc804b7 100644 --- a/tests/java5/generics/genericaspects/GenericAspectT.aj +++ b/tests/java5/generics/genericaspects/GenericAspectT.aj @@ -4,11 +4,11 @@ import org.aspectj.lang.annotation.*; aspect ParentChildRelationship { - interface I<P>{} + interface I<P extends I>{} public String I.parent; - public void I<T>.do(T a) { + public void I<T>.abc(T a) { a.parent=null; } diff --git a/tests/java5/generics/genericaspects/GenericAspectU.aj b/tests/java5/generics/genericaspects/GenericAspectU.aj index 8ed1f100e..7197a51f0 100644 --- a/tests/java5/generics/genericaspects/GenericAspectU.aj +++ b/tests/java5/generics/genericaspects/GenericAspectU.aj @@ -2,6 +2,7 @@ import java.util.*; import java.lang.reflect.*; import org.aspectj.lang.annotation.*; + abstract aspect ParentChildRelationship<Parent,Child> { interface ParentHasChildren<C>{} @@ -22,27 +23,25 @@ abstract aspect ParentChildRelationship<Parent,Child> { } public void ChildHasParent<R>.setParent(R parent) { -// parent.addChild(this); + ((ParentHasChildren)parent).addChild(this); } public void ParentHasChildren<X>.addChild(X child) { - //if (child.parent != null) { - //child.parent.removeChild(child); - // } + if (((ChildHasParent)child).parent != null) { + ((ParentHasChildren)((ChildHasParent)child).parent).removeChild(child); + } children.add(child); } -/* public void ParentHasChildren<Y>.removeChild(Y child) { if (children.remove(child)) { - child.parent = null; + ((ChildHasParent)child).parent = null; } } -*/ } -aspect GenericAspectT extends ParentChildRelationship<Top,Bottom> { +aspect GenericAspectU extends ParentChildRelationship<Top,Bottom> { public static void main(String []argv) { @@ -92,7 +91,7 @@ aspect GenericAspectT extends ParentChildRelationship<Top,Bottom> { "parent check 1 failed "+ "retrieved="+retrievedParent+" expected="+t); -/* + Top top2 = new Top(); b.setParent(top2); Top retrievedParent2 = b.getParent(); @@ -102,12 +101,12 @@ aspect GenericAspectT extends ParentChildRelationship<Top,Bottom> { Bottom bot2 = new Bottom(); top2.addChild(bot2); - //Bottom aBottom = top2.getChildren().get(0); - //check(aBottom==bot2,"Incorrect child? expected="+bot2+" found="+aBottom); - //top2.removeChild(bot2); - //int size=top2.getChildren().size(); - //check(size==0,"Should be no children but there were "+size); -*/ + Bottom aBottom = top2.getChildren().get(0); + check(aBottom==bot2,"Incorrect child? expected="+bot2+" found="+aBottom); + top2.removeChild(bot2); + int size=top2.getChildren().size(); + check(size==0,"Should be no children but there were "+size); + } diff --git a/tests/java5/generics/genericaspects/ParentChildRelationship.aj b/tests/java5/generics/genericaspects/ParentChildRelationship.aj index 3e34e3afd..6d9624d6d 100644 --- a/tests/java5/generics/genericaspects/ParentChildRelationship.aj +++ b/tests/java5/generics/genericaspects/ParentChildRelationship.aj @@ -1,61 +1,86 @@ import java.util.*; +import org.aspectj.lang.annotation.*; +abstract aspect ParentChildRelationship<Parent,Child> { -public abstract aspect ParentChildRelationship<P,C> { - - /** - * Parents contain a list of children - */ - private List<C> P.children; - - /** - * Each child has a parent - */ - private P C.parent; + /** interface implemented by parents */ + interface ParentHasChildren<C>{ +// List<C> getChildren(); +// void addChild(C child); +// void removeChild(C child); + } + + /** interface implemented by children */ + interface ChildHasParent<P>{ +// P getParent(); +// void setParent(P parent); + } + + /** ensure the parent type implements ParentHasChildren<child type> */ + declare parents: Parent implements ParentHasChildren<Child>; + + /** ensure the child type implements ChildHasParent<parent type> */ + declare parents: Child implements ChildHasParent<Parent>; + + // Inter-type declarations made on the *generic* interface types to provide + // default implementations. + + /** list of children maintained by parent */ + public List<E> ParentHasChildren<E>.children = new ArrayList<E>(); + + /** reference to parent maintained by child */ + public P ChildHasParent<P>.parent; + + /** Default implementation of getChildren for the generic type ParentHasChildren */ + public List<D> ParentHasChildren<D>.getChildren() { + return Collections.unmodifiableList(children); + } + + /** Default implementation of getParent for the generic type ChildHasParent */ + public P ChildHasParent<P>.getParent() { + return parent; + } /** - * Parents provide access to their children + * Default implementation of setParent for the generic type ChildHasParent. + * Ensures that this child is added to the children of the parent too. */ - public List<C> P.getChildren() { - return Collections.unmodifiableList(children); - } - - /** - * A child provides access to its parent - */ - public P C.getParent() { - return parent; - } - - /** - * ensure bi-directional navigation on adding a child - */ - public void P.addChild(C child) { - if (child.parent != null) { - child.parent.removeChild(child); - } - children.add(child); - child.parent = this; - } + public void ChildHasParent<R>.setParent(R parent) { + ((ParentHasChildren)parent).addChild(this); + } - /** - * ensure bi-directional navigation on removing a child - */ - public void P.removeChild(C child) { - if (children.remove(child)) { - child.parent = null; - } + /** + * Default implementation of addChild, ensures that parent of child is + * also updated. + */ + public void ParentHasChildren<X>.addChild(X child) { + if (((ChildHasParent)child).parent != null) { + ((ParentHasChildren)((ChildHasParent)child).parent).removeChild(child); } + children.add(child); + ((ChildHasParent)child).parent = (ParentHasChildren)this; + } /** - * ensure bi-directional navigation on setting parent + * Default implementation of removeChild, ensures that parent of + * child is also updated. */ - public void C.setParent(P parent) { - parent.addChild(this); + public void ParentHasChildren<Y>.removeChild(Y child) { + if (children.remove(child)) { + ((ChildHasParent)child).parent = null; } - - public pointcut addingChild(P p, C c) : - execution(* P.addChild(C)) && this(p) && args(c); + } + /** + * Matches at an addChild join point for the parent type P and child type C + */ + @SuppressAjWarnings + public pointcut addingChild(Parent p, Child c) : + execution(* Parent.addChild(Child)) && this(p) && args(c); - public pointcut removingChild(P p, C c) : - execution(* P.removeChild(C)) && this(p) && args(c); + /** + * Matches at a removeChild join point for the parent type P and child type C + */ + @SuppressAjWarnings + public pointcut removingChild(Parent p, Child c) : + execution(* Parent.removeChild(Child)) && this(p) && args(c); + } diff --git a/tests/java5/generics/itds/Parse5.java b/tests/java5/generics/itds/Parse5.java index c322f006d..30514a5d9 100644 --- a/tests/java5/generics/itds/Parse5.java +++ b/tests/java5/generics/itds/Parse5.java @@ -2,15 +2,15 @@ public class Parse5<T,S extends Number> {} aspect X { - String Parse5.m1() {} + void Parse5.m1() {} - String Parse5<Q,R extends Number>.m2() {} + void Parse5<Q,R>.m2() {} - String Parse5<T,V>.m3() {} // error + void Parse5<T,V>.m3() {} - String Parse5<A,B extends Number,C>.m4() {} // error + void Parse5<A,B,C>.m4() {} // error - String Parse5<A>.m5() {} // error + void Parse5<A>.m5() {} // error - String Parse5<String,Integer>.m6() {} // error + void Parse5<String,Integer>.m6() {} // error } diff --git a/tests/java5/generics/itds/binaryweaving/A1.aj b/tests/java5/generics/itds/binaryweaving/A1.aj index 005d9dc2d..c1a25632a 100644 --- a/tests/java5/generics/itds/binaryweaving/A1.aj +++ b/tests/java5/generics/itds/binaryweaving/A1.aj @@ -7,7 +7,7 @@ aspect A1 { after(BaseClass c): execution(* run1(..)) && this(c) { List<String> myLs = new ArrayList<String>(); c.list1 = myLs; - System.err.println("Advice from A1 ran successfully"); + c.count++; } } diff --git a/tests/java5/generics/itds/binaryweaving/A2.aj b/tests/java5/generics/itds/binaryweaving/A2.aj index 20fb8baf5..1837d3e0a 100644 --- a/tests/java5/generics/itds/binaryweaving/A2.aj +++ b/tests/java5/generics/itds/binaryweaving/A2.aj @@ -1,13 +1,14 @@ import java.util.*; aspect A2 { +// declare precedence: A2,A1; public List<Z> BaseClass<Z>.list2; after(): execution(* run2(..)) { BaseClass<Integer> bInt = new BaseClass<Integer>(); bInt.list2 = new ArrayList<Integer>(); - System.err.println("Advice from A2 ran successfully"); + bInt.count++; } } diff --git a/tests/java5/generics/itds/binaryweaving/A3.aj b/tests/java5/generics/itds/binaryweaving/A3.aj index cacd30e0d..66f80ba0a 100644 --- a/tests/java5/generics/itds/binaryweaving/A3.aj +++ b/tests/java5/generics/itds/binaryweaving/A3.aj @@ -2,6 +2,8 @@ import java.util.*; aspect A3 { +// declare precedence: A3,A2; + public List<Z> BaseClass<Z>.m(List<Z> lz) { return lz; } @@ -10,7 +12,7 @@ aspect A3 { List<String> myLs = new ArrayList<String>(); BaseClass<String> bStr = new BaseClass<String>(); List<String> ls2 = bStr.m(myLs); - System.err.println("Advice from A3 ran successfully"); + bStr.count++; } } diff --git a/tests/java5/generics/itds/binaryweaving/BaseClass.java b/tests/java5/generics/itds/binaryweaving/BaseClass.java index edd3e4c93..225dddd46 100644 --- a/tests/java5/generics/itds/binaryweaving/BaseClass.java +++ b/tests/java5/generics/itds/binaryweaving/BaseClass.java @@ -1,9 +1,12 @@ public class BaseClass<N> { + static int count = 0; + public static void main(String[]argv) { BaseClass b = new BaseClass(); b.run1(); b.run2(); b.run3(); + System.err.println("Advice count="+count); } public void run1() {} diff --git a/tests/java5/generics/itds/binaryweaving/TestA_aspect.aj b/tests/java5/generics/itds/binaryweaving/TestA_aspect.aj new file mode 100644 index 000000000..d2c423942 --- /dev/null +++ b/tests/java5/generics/itds/binaryweaving/TestA_aspect.aj @@ -0,0 +1,6 @@ +import java.util.*; + +aspect TestA_aspect { + // scary, multiple tvars, one from member, one from target + public <L extends Number> void TestA_generictype<Z>.m(List<L> ll1, List<Z> lz,List<L> ll2) {} +} diff --git a/tests/java5/generics/itds/binaryweaving/TestA_class.java b/tests/java5/generics/itds/binaryweaving/TestA_class.java new file mode 100644 index 000000000..b5c6c01cd --- /dev/null +++ b/tests/java5/generics/itds/binaryweaving/TestA_class.java @@ -0,0 +1,10 @@ +import java.util.*; + +public class TestA_class { + public static void main(String []argv) { + TestA_generictype<Float> sc = new TestA_generictype<Float>(); + List<Integer> li = new ArrayList<Integer>(); + List<Float> lf = new ArrayList<Float>(); + sc.m(li,lf,li); + } +} diff --git a/tests/java5/generics/itds/binaryweaving/TestA_generictype.java b/tests/java5/generics/itds/binaryweaving/TestA_generictype.java new file mode 100644 index 000000000..005d936a0 --- /dev/null +++ b/tests/java5/generics/itds/binaryweaving/TestA_generictype.java @@ -0,0 +1,4 @@ +import java.util.*; + +class TestA_generictype<N> {// extends Number> { +} diff --git a/tests/java5/generics/itds/sharing/GenericAspectA.aj b/tests/java5/generics/itds/sharing/GenericAspectA.aj deleted file mode 100644 index fcb3090ea..000000000 --- a/tests/java5/generics/itds/sharing/GenericAspectA.aj +++ /dev/null @@ -1,19 +0,0 @@ -// Simple - adding an interface to a type via a generic aspect and decp -abstract aspect GenericAspect<A> { - - declare parents: A implements SimpleI; - - interface SimpleI {} - -} - -aspect GenericAspectA extends GenericAspect<Base> { - public static void main(String []argv) { - Base b = new Base(); - if (!(b instanceof SimpleI)) - throw new RuntimeException("Base should implement SimpleI!"); - } -} - -class Base {} - diff --git a/tests/java5/generics/itds/sharing/GenericAspectB.aj b/tests/java5/generics/itds/sharing/GenericAspectB.aj deleted file mode 100644 index 39d262223..000000000 --- a/tests/java5/generics/itds/sharing/GenericAspectB.aj +++ /dev/null @@ -1,19 +0,0 @@ -// Decp a generic interface -abstract aspect GenericAspect<A> { - - declare parents: A implements SimpleI; - - interface SimpleI<X> {} - -} - -aspect GenericAspectB extends GenericAspect<Base> { - public static void main(String []argv) { - Base b = new Base(); - if (!(b instanceof SimpleI)) - throw new RuntimeException("Base should implement SimpleI!"); - } -} - -class Base {} - diff --git a/tests/java5/generics/itds/sharing/GenericAspectC.aj b/tests/java5/generics/itds/sharing/GenericAspectC.aj deleted file mode 100644 index 3e1d6c6ee..000000000 --- a/tests/java5/generics/itds/sharing/GenericAspectC.aj +++ /dev/null @@ -1,24 +0,0 @@ -// Decp an interface with an ITD method on it -abstract aspect GenericAspect<A> { - - interface SimpleI {} - - declare parents: A implements SimpleI; - - public int SimpleI.m() { return 4;} - -} - -aspect GenericAspectC extends GenericAspect<Base> { - public static void main(String []argv) { - Base b = new Base(); - - if (!(b instanceof SimpleI)) - throw new RuntimeException("Base should implement SimpleI!"); - - int i = b.m(); - } -} - -class Base {} - diff --git a/tests/java5/generics/itds/sharing/GenericAspectD.aj b/tests/java5/generics/itds/sharing/GenericAspectD.aj deleted file mode 100644 index 30775a593..000000000 --- a/tests/java5/generics/itds/sharing/GenericAspectD.aj +++ /dev/null @@ -1,24 +0,0 @@ -// Decp an interface with an ITD field -abstract aspect GenericAspect<A> { - - interface SimpleI {} - - declare parents: A implements SimpleI; - - public int SimpleI.n; - -} - -aspect GenericAspectD extends GenericAspect<Base> { - public static void main(String []argv) { - Base b = new Base(); - - if (!(b instanceof SimpleI)) - throw new RuntimeException("Base should implement SimpleI!"); - - b.n=42; - } -} - -class Base {} - diff --git a/tests/java5/generics/itds/sharing/GenericAspectE.aj b/tests/java5/generics/itds/sharing/GenericAspectE.aj deleted file mode 100644 index 60bf8cd53..000000000 --- a/tests/java5/generics/itds/sharing/GenericAspectE.aj +++ /dev/null @@ -1,18 +0,0 @@ -abstract aspect GenericAspect<A> { - - declare parents: A implements IUtil; - - //public void IUtil<Z>.print(Z n) { System.err.println(n); } -} - -interface IUtil<N extends Number> { } - -aspect GenericAspectE extends GenericAspect<Base> { - public static void main(String []argv) { - Base b = new Base(); - // b.print("hello"); - } -} - -class Base {} - diff --git a/tests/java5/generics/itds/sharing/MethodA4.aj b/tests/java5/generics/itds/sharing/MethodA4.aj index 64c2aced0..192a7dc98 100644 --- a/tests/java5/generics/itds/sharing/MethodA4.aj +++ b/tests/java5/generics/itds/sharing/MethodA4.aj @@ -12,6 +12,8 @@ class Base<N extends Number> { } aspect X { public List<Z> Base<Z>.m() { // OK, Z becomes N in return type List<Z> lz = new ArrayList<Z>(); + List<String> ls; + return lz; }; } diff --git a/tests/java5/generics/itds/sharing/MethodQ.aj b/tests/java5/generics/itds/sharing/MethodQ.aj index bfe415a28..979c3b39a 100644 --- a/tests/java5/generics/itds/sharing/MethodQ.aj +++ b/tests/java5/generics/itds/sharing/MethodQ.aj @@ -9,7 +9,7 @@ public class MethodQ { } } -class SimpleClass<N extends Number> { +class SimpleClass<N> {// extends Number> { // This is what we are trying to mimic with our ITD //public <L extends Number> void m(List<L> ll1, List<N> lz,List<L> ll2) {} } diff --git a/tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java b/tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java index 43200dfb2..5adfad3f6 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java @@ -152,22 +152,26 @@ public class GenericsTests extends XMLBasedAjcTestCase { * PASS multiple type variables in an ITD * PASS parsing ITDs that share type variables with target type * PASS using type variables from the target type in your field ITD - * TODO using type variables from the target type in your method ITD (but no type vars of your own) - * TODO using type variables from the target type in your ctor ITD (but no type vars of your own) - * TODO using type variables from the target type in your *STATIC* ITD (field/method/ctor) - * TODO binary weaving with changing types (moving between generic and simple) - * TODO bridge method creation - * TODO reusing type variable letter but differing spec across multiple ITDs in one aspect + * PASS using type variables from the target type in your method ITD (but no type vars of your own) + * PASS using type variables from the target type in your ctor ITD (but no type vars of your own) + * PASS using type variables from the target type and having your own too (methods) + * PASS using type variables from the target type and having your own too (ctors) + * PASS reusing type variable letter but differing spec across multiple ITDs in one aspect * PASS wildcards - * TODO exotic class/interface bounds ('? extends List<String>') * PASS recursive type variable definitions - * TODO generic aspects - * TODO parameterizing ITDs with type variables - * - * defer? - * TODO using type variables from the target type and having your own too (methods) - * TODO using type variables from the target type and having your own too (ctors) + * PASS generic aspects + * PASS parameterizing ITDs with type variables + * TODO using type variables from the target type in your *STATIC* ITD (field/method/ctor) (error scenario) + * TODO binary weaving with changing types (moving between generic and simple) + * TODO bridge method creation (also relates to covariance overrides..) + * TODO exotic class/interface bounds ('? extends List<String>','? super anything') * TODO signature attributes for generic ITDs (public only?) + * TODO generic aspect binary weaving (or at least multi source file weaving) + * + * + * strangeness: + * + * adding declare precedence into the itds/binaryweaving A2.aj, A3.aj causes a bizarre classfile inconsistent message */ public static Test suite() { @@ -236,8 +240,8 @@ public class GenericsTests extends XMLBasedAjcTestCase { public void testParseItdStaticMethod() {runTest("Parsing generic ITDs - 2");} public void testParseItdCtor() {runTest("Parsing generic ITDs - 3");} public void testParseItdComplexMethod() {runTest("Parsing generic ITDs - 4");} -// public void testParseItdSharingVars1() {runTest("Parsing generic ITDs - 5");} -// public void testParseItdSharingVars2() {runTest("Parsing generic ITDs - 6");} + public void testParseItdSharingVars1() {runTest("Parsing generic ITDs - 5");} + public void testParseItdSharingVars2() {runTest("Parsing generic ITDs - 6");} // non static @@ -304,6 +308,74 @@ public class GenericsTests extends XMLBasedAjcTestCase { public void testFieldITDsUsingTargetTypeVars15(){runTest("field itd using type variable from target type -15");} public void testFieldITDsUsingTargetTypeVars16(){runTest("field itd using type variable from target type -16");} + + public void testMethodITDsUsingTargetTypeVarsA1() {runTest("method itd using type variable from target type - A1");} + public void testMethodITDsUsingTargetTypeVarsA2() {runTest("method itd using type variable from target type - A2");} + public void testMethodITDsUsingTargetTypeVarsA3() {runTest("method itd using type variable from target type - A3");} + public void testMethodITDsUsingTargetTypeVarsA4() {runTest("method itd using type variable from target type - A4");} + public void testMethodITDsUsingTargetTypeVarsB1() {runTest("method itd using type variable from target type - B1");} + public void testMethodITDsUsingTargetTypeVarsC1() {runTest("method itd using type variable from target type - C1");} + public void testMethodITDsUsingTargetTypeVarsD1() {runTest("method itd using type variable from target type - D1");} + public void testMethodITDsUsingTargetTypeVarsE1() {runTest("method itd using type variable from target type - E1");} + public void testMethodITDsUsingTargetTypeVarsF1() {runTest("method itd using type variable from target type - F1");} + public void testMethodITDsUsingTargetTypeVarsG1() {runTest("method itd using type variable from target type - G1");} + public void testMethodITDsUsingTargetTypeVarsH1() {runTest("method itd using type variable from target type - H1");} + public void testMethodITDsUsingTargetTypeVarsI1() {runTest("method itd using type variable from target type - I1");} + public void testMethodITDsUsingTargetTypeVarsI2() {runTest("method itd using type variable from target type - I2");} + public void testMethodITDsUsingTargetTypeVarsJ1() {runTest("method itd using type variable from target type - J1");} + public void testMethodITDsUsingTargetTypeVarsK1() {runTest("method itd using type variable from target type - K1");} + public void testMethodITDsUsingTargetTypeVarsL1() {runTest("method itd using type variable from target type - L1");} + public void testMethodITDsUsingTargetTypeVarsM1() {runTest("method itd using type variable from target type - M1");} + public void testMethodITDsUsingTargetTypeVarsM2() {runTest("method itd using type variable from target type - M2");} + public void testMethodITDsUsingTargetTypeVarsN1() {runTest("method itd using type variable from target type - N1");} + public void testMethodITDsUsingTargetTypeVarsO1() {runTest("method itd using type variable from target type - O1");} + public void testMethodITDsUsingTargetTypeVarsO2() {runTest("method itd using type variable from target type - O2");} + public void testMethodITDsUsingTargetTypeVarsP1() {runTest("method itd using type variable from target type - P1");} + public void testMethodITDsUsingTargetTypeVarsQ1() {runTest("method itd using type variable from target type - Q1");} + + public void testCtorITDsUsingTargetTypeVarsA1() {runTest("ctor itd using type variable from target type - A1");} + public void testCtorITDsUsingTargetTypeVarsB1() {runTest("ctor itd using type variable from target type - B1");} + public void testCtorITDsUsingTargetTypeVarsC1() {runTest("ctor itd using type variable from target type - C1");} + public void testCtorITDsUsingTargetTypeVarsD1() {runTest("ctor itd using type variable from target type - D1");} + public void testCtorITDsUsingTargetTypeVarsE1() {runTest("ctor itd using type variable from target type - E1");} + public void testCtorITDsUsingTargetTypeVarsF1() {runTest("ctor itd using type variable from target type - F1");} + public void testCtorITDsUsingTargetTypeVarsG1() {runTest("ctor itd using type variable from target type - G1");} + public void testCtorITDsUsingTargetTypeVarsH1() {runTest("ctor itd using type variable from target type - H1");} + public void testCtorITDsUsingTargetTypeVarsI1() {runTest("ctor itd using type variable from target type - I1");} + + public void testSophisticatedAspectsA() {runTest("uberaspects - A");} + public void testSophisticatedAspectsB() {runTest("uberaspects - B");} + public void testSophisticatedAspectsC() {runTest("uberaspects - C");} + public void testSophisticatedAspectsD() {runTest("uberaspects - D");} + public void testSophisticatedAspectsE() {runTest("uberaspects - E");} + public void testSophisticatedAspectsF() {runTest("uberaspects - F");} + public void testSophisticatedAspectsG() {runTest("uberaspects - G");} + public void testSophisticatedAspectsH() {runTest("uberaspects - H");} + public void testSophisticatedAspectsI() {runTest("uberaspects - I");} + public void testSophisticatedAspectsJ() {runTest("uberaspects - J");} +// public void testSophisticatedAspectsK() {runTest("uberaspects - K");} // FIXME asc needs some error messages writing + public void testSophisticatedAspectsL() {runTest("uberaspects - L");} +// public void testSophisticatedAspectsM() {runTest("uberaspects - M");} // FIXME asc needs some error messages writing + public void testSophisticatedAspectsN() {runTest("uberaspects - N");} +// public void testSophisticatedAspectsO() {runTest("uberaspects - O");} // FIXME asc needs some error messages writing + public void testSophisticatedAspectsP() {runTest("uberaspects - P");} + public void testSophisticatedAspectsQ() {runTest("uberaspects - Q");} + public void testSophisticatedAspectsR() {runTest("uberaspects - R");} + public void testSophisticatedAspectsS() {runTest("uberaspects - S");} + public void testSophisticatedAspectsT() {runTest("uberaspects - T");} + + //public void testSophisticatedAspectsU() {runTest("uberaspects - U");} + + public void testBinaryWeavingITDsA() {runTest("binary weaving ITDs - A");} + + // ?? Looks like reweavable files dont process their type mungers correctly. + // See AjLookupEnvironment.weaveInterTypeDeclarations(SourceTypeBinding,typeMungers,declareparents,...) + // it seems to process any it discovers from the weaver state info then not apply new ones (the ones + // passed in!) +// public void testBinaryWeavingITDs1() {runTest("binary weaving ITDs - 1");} +// public void testBinaryWeavingITDs2() {runTest("binary weaving ITDs - 2");} +// public void testBinaryWeavingITDs3() {runTest("binary weaving ITDs - 3");} + // general tests ... usually just more complex scenarios public void testReusingTypeVariableLetters() {runTest("reusing type variable letters");} @@ -405,10 +477,6 @@ public class GenericsTests extends XMLBasedAjcTestCase { // runTest("Problems resolving type name inside generic class"); // } - // missing tests in here: - - // 1. public ITDs and separate compilation - are the signatures correct for the new public members? - // 2. ITDF // -- Pointcut tests... @@ -631,6 +699,7 @@ public class GenericsTests extends XMLBasedAjcTestCase { runTest("ajdk notebook: pointcut in generic class example"); } + // --- helpers // Check the signature attribute on a class is correct diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index 1abf02a21..4f069aa52 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -2876,6 +2876,265 @@ </compile> </ajc-test> + <!-- Now intertype declared methods on generic types that use the target types type vars --> + + <ajc-test dir="java5/generics/itds/sharing" title="method itd using type variable from target type - A1"> + <compile files="MethodA.aj" options="-1.5"/> + <run class="MethodA"/> + </ajc-test> + <ajc-test dir="java5/generics/itds/sharing" title="method itd using type variable from target type - A2"> + <compile files="MethodA2.aj" options="-1.5"/> + <run class="MethodA2"/> + </ajc-test> + <ajc-test dir="java5/generics/itds/sharing" title="method itd using type variable from target type - A3"> + <compile files="MethodA3.aj" options="-1.5"/> + <run class="MethodA3"/> + </ajc-test> + <ajc-test dir="java5/generics/itds/sharing" title="method itd using type variable from target type - A4"> + <compile files="MethodA4.aj" options="-1.5"/> + <run class="MethodA4"/> + </ajc-test> + + <ajc-test dir="java5/generics/itds/sharing" title="method itd using type variable from target type - B1"> + <compile files="MethodB.aj" options="-1.5"> + <message kind="error" line="16" text="Incorrect number of type parameters supplied. The generic type Base<N,M> has 2 type parameters, not 1."/> + </compile> + </ajc-test> + + <ajc-test dir="java5/generics/itds/sharing" title="method itd using type variable from target type - C1"> + <compile files="MethodC.aj" options="-1.5"/> + <run class="MethodC"/> + </ajc-test> + + <ajc-test dir="java5/generics/itds/sharing" title="method itd using type variable from target type - D1"> + <compile files="MethodD.aj" options="-1.5"/> + <run class="MethodD"/> + </ajc-test> + + <ajc-test dir="java5/generics/itds/sharing" title="method itd using type variable from target type - E1"> + <compile files="MethodE.aj" options="-1.5"/> + <run class="MethodE"/> + </ajc-test> + + <ajc-test dir="java5/generics/itds/sharing" title="method itd using type variable from target type - F1"> + <compile files="MethodF.aj" options="-1.5"/> + <run class="MethodF"/> + </ajc-test> + + <ajc-test dir="java5/generics/itds/sharing" title="method itd using type variable from target type - G1"> + <compile files="MethodG.aj" options="-1.5"/> + <run class="MethodG"/> + </ajc-test> + + <ajc-test dir="java5/generics/itds/sharing" title="method itd using type variable from target type - H1"> + <compile files="MethodH.aj" options="-1.5"/> + <run class="MethodH"/> + </ajc-test> + + <ajc-test dir="java5/generics/itds/sharing" title="method itd using type variable from target type - I1"> + <compile files="MethodI.aj" options="-1.5"> + <message kind="error" line="6" text="Type mismatch: cannot convert from List<Integer> to List<String>"/> + </compile> + </ajc-test> + + <ajc-test dir="java5/generics/itds/sharing" title="method itd using type variable from target type - I2"> + <compile files="MethodI2.aj" options="-1.5"> + <message kind="error" line="7" text="The method m(List<Integer>) in the type Base<N> is not applicable for the arguments (List<String>)"/> + </compile> + </ajc-test> + + <ajc-test dir="java5/generics/itds/sharing" title="method itd using type variable from target type - J1"> + <compile files="MethodJ.aj" options="-1.5"/> + <run class="MethodJ"/> + </ajc-test> + + <ajc-test dir="java5/generics/itds/sharing" title="method itd using type variable from target type - K1"> + <compile files="MethodK.aj" options="-1.5"/> + <run class="MethodK"/> + </ajc-test> + + <ajc-test dir="java5/generics/itds/sharing" title="method itd using type variable from target type - L1"> + <compile files="MethodL.aj" options="-1.5"/> + <run class="MethodL"/> + </ajc-test> + + <ajc-test dir="java5/generics/itds/sharing" title="method itd using type variable from target type - M1"> + <compile files="MethodM.aj" options="-1.5"/> + <run class="MethodM"/> + </ajc-test> + <ajc-test dir="java5/generics/itds/sharing" title="method itd using type variable from target type - M2"> + <compile files="MethodM2.aj" options="-1.5"/> + <run class="MethodM2"/> + </ajc-test> + + <ajc-test dir="java5/generics/itds/sharing" title="method itd using type variable from target type - N1"> + <compile files="MethodN.aj" options="-1.5"> + <message kind="error" line="11" text="Type parameters can not be specified in the ITD target type - the target type I is not generic."/> + </compile> + </ajc-test> + + <ajc-test dir="java5/generics/itds/sharing" title="method itd using type variable from target type - O1"> + <compile files="MethodO.aj" options="-1.5"> + <message kind="error" line="11" text="Intertype declarations can only be made on the generic type, not on a parameterized type. The name 'String' cannot be used as a type parameter, since it refers to a real type."/> + </compile> + </ajc-test> + <ajc-test dir="java5/generics/itds/sharing" title="method itd using type variable from target type - O2"> + <compile files="MethodO2.aj" options="-1.5"> + <message kind="error" line="11" text="Intertype declarations can only be made on the generic type, not on a parameterized type. The name 'String' cannot be used as a type parameter, since it refers to a real type."/> + </compile> + </ajc-test> + + <ajc-test dir="java5/generics/itds/sharing" title="method itd using type variable from target type - P1"> + <compile files="MethodP.aj" options="-1.5"/> + <run class="MethodP"/> + </ajc-test> + + <ajc-test dir="java5/generics/itds/sharing" title="method itd using type variable from target type - Q1"> + <compile files="MethodQ.aj" options="-1.5"/> + <run class="MethodQ"/> + </ajc-test> + + <!-- Now intertype declared constructors on generic types that use the target types type vars --> + + <ajc-test dir="java5/generics/itds/sharing" title="ctor itd using type variable from target type - A1"> + <compile files="CtorA.aj" options="-1.5"/> + <run class="CtorA"/> + </ajc-test> + + <ajc-test dir="java5/generics/itds/sharing" title="ctor itd using type variable from target type - B1"> + <compile files="CtorB.aj" options="-1.5"> + <message kind="error" line="15" text="Incorrect number of type parameters supplied. The generic type Base<N,M> has 2 type parameters, not 1."/> + </compile> + </ajc-test> + + <ajc-test dir="java5/generics/itds/sharing" title="ctor itd using type variable from target type - C1"> + <compile files="CtorC.aj" options="-1.5"/> + <run class="CtorC"/> + </ajc-test> + + <ajc-test dir="java5/generics/itds/sharing" title="ctor itd using type variable from target type - D1"> + <compile files="CtorD.aj" options="-1.5"/> + <run class="CtorD"/> + </ajc-test> + + <ajc-test dir="java5/generics/itds/sharing" title="ctor itd using type variable from target type - E1"> + <compile files="CtorE.aj" options="-1.5"/> + <run class="CtorE"/> + </ajc-test> + + <ajc-test dir="java5/generics/itds/sharing" title="ctor itd using type variable from target type - F1"> + <compile files="CtorF.aj" options="-1.5"/> + <run class="CtorF"/> + </ajc-test> + + <ajc-test dir="java5/generics/itds/sharing" title="ctor itd using type variable from target type - G1"> + <compile files="CtorG.aj" options="-1.5"/> + <run class="CtorG"/> + </ajc-test> + + <ajc-test dir="java5/generics/itds/sharing" title="ctor itd using type variable from target type - H1"> + <compile files="CtorH.aj" options="-1.5"/> + <run class="CtorH"/> + </ajc-test> + + <ajc-test dir="java5/generics/itds/sharing" title="ctor itd using type variable from target type - I1"> + <compile files="CtorI.aj" options="-1.5"/> + <run class="CtorI"/> + </ajc-test> + + <!-- putting it all together, fields/methods/ctors and decps --> + + <ajc-test dir="java5/generics/genericaspects/" title="uberaspects - A"> + <compile files="GenericAspectA.aj" options="-1.5"/> + <run class="GenericAspectA"/> + </ajc-test> + <ajc-test dir="java5/generics/genericaspects/" title="uberaspects - B"> + <compile files="GenericAspectB.aj" options="-1.5"/> + <run class="GenericAspectB"/> + </ajc-test> + <ajc-test dir="java5/generics/genericaspects/" title="uberaspects - C"> + <compile files="GenericAspectC.aj" options="-1.5"/> + <run class="GenericAspectC"/> + </ajc-test> + <ajc-test dir="java5/generics/genericaspects/" title="uberaspects - D"> + <compile files="GenericAspectD.aj" options="-1.5"/> + <run class="GenericAspectD"/> + </ajc-test> + <ajc-test dir="java5/generics/genericaspects/" title="uberaspects - E"> + <compile files="GenericAspectE.aj" options="-1.5"/> + <run class="GenericAspectE"/> + </ajc-test> + <ajc-test dir="java5/generics/genericaspects/" title="uberaspects - F"> + <compile files="GenericAspectF.aj" options="-1.5"/> + <run class="GenericAspectF"/> + </ajc-test> + <ajc-test dir="java5/generics/genericaspects/" title="uberaspects - G"> + <compile files="GenericAspectG.aj" options="-1.5"/> + <run class="GenericAspectG"/> + </ajc-test> + <ajc-test dir="java5/generics/genericaspects/" title="uberaspects - H"> + <compile files="GenericAspectH.aj" options="-1.5"> + <message kind="error" line="7" text="Type java.lang.String does not meet the specification for type parameter 1 (N extends java.lang.Number) in generic type GenericAspect$SimpleI"/> + <message kind="error" line="16" text="The method m4(String) is undefined for the type Base"/> + </compile> + </ajc-test> + <ajc-test dir="java5/generics/genericaspects/" title="uberaspects - I"> + <compile files="GenericAspectI.aj" options="-1.5"/> + <run class="GenericAspectI"/> + </ajc-test> + <ajc-test dir="java5/generics/genericaspects/" title="uberaspects - J"> + <compile files="GenericAspectJ.aj" options="-1.5"/> + <run class="GenericAspectJ"/> + </ajc-test> + <ajc-test dir="java5/generics/genericaspects/" title="uberaspects - K"> + <compile files="GenericAspectK.aj" options="-1.5"/> + <!-- will need error messages in here --> + <run class="GenericAspectK"/> + </ajc-test> + <ajc-test dir="java5/generics/genericaspects/" title="uberaspects - L"> + <compile files="GenericAspectL.aj" options="-1.5"/> + <run class="GenericAspectL"/> + </ajc-test> + <ajc-test dir="java5/generics/genericaspects/" title="uberaspects - M"> + <compile files="GenericAspectM.aj" options="-1.5"/> + <!-- will need error messages in here --> + <run class="GenericAspectM"/> + </ajc-test> + <ajc-test dir="java5/generics/genericaspects/" title="uberaspects - N"> + <compile files="GenericAspectN.aj" options="-1.5"/> + <run class="GenericAspectN"/> + </ajc-test> + <ajc-test dir="java5/generics/genericaspects/" title="uberaspects - O"> + <compile files="GenericAspectO.aj" options="-1.5"/> + <!-- will need error messages in here --> + <run class="GenericAspectO"/> + </ajc-test> + <ajc-test dir="java5/generics/genericaspects/" title="uberaspects - P"> + <compile files="GenericAspectP.aj" options="-1.5"/> + <run class="GenericAspectP"/> + </ajc-test> + <ajc-test dir="java5/generics/genericaspects/" title="uberaspects - Q"> + <compile files="GenericAspectQ.aj" options="-1.5"/> + <run class="GenericAspectQ"/> + </ajc-test> + <ajc-test dir="java5/generics/genericaspects/" title="uberaspects - R"> + <compile files="GenericAspectR.aj" options="-1.5"/> + <run class="GenericAspectR"/> + </ajc-test> + <ajc-test dir="java5/generics/genericaspects/" title="uberaspects - S"> + <compile files="GenericAspectS.aj" options="-1.5"/> + <run class="GenericAspectS"/> + </ajc-test> + <ajc-test dir="java5/generics/genericaspects/" title="uberaspects - T"> + <compile files="GenericAspectT.aj" options="-1.5"/> + </ajc-test> + <ajc-test dir="java5/generics/genericaspects/" title="uberaspects - U"> + <compile files="GenericAspectU.aj" options="-1.5"/> + <run class="GenericAspectU"/> + </ajc-test> + + + <ajc-test dir="java5/generics/itds/sharing" title="method itd sharing type variable with generic type"> <compile files="Simple.aj" options="-1.5"/> <run class="Simple"/> @@ -2928,7 +3187,11 @@ </ajc-test> <ajc-test dir="java5/generics/itds" title="Parsing generic ITDs - 5"> - <compile files="Parse5.java" options="-1.5"/> + <compile files="Parse5.java" options="-1.5"> + <message kind="error" line="11" text="Incorrect number of type parameters supplied. The generic type Parse5<T,S> has 2 type parameters, not 3."/> + <message kind="error" line="13" text="Incorrect number of type parameters supplied. The generic type Parse5<T,S> has 2 type parameters, not 1."/> + <message kind="error" line="15" text="Intertype declarations can only be made on the generic type, not on a parameterized type. The name 'String' cannot be used as a type parameter, since it refers to a real type."/> + </compile> </ajc-test> <ajc-test dir="java5/generics/itds" title="Parsing generic ITDs - 6"> @@ -3016,23 +3279,36 @@ <!-- generics/itds and binary weaving --> + <ajc-test dir="java5/generics/itds/binaryweaving" vm="1.5" title="binary weaving ITDs - A"> + <compile files="TestA_generictype.java" outjar="code.jar" options="-1.5,-Xreweavable"/> + <compile files="TestA_aspect.aj,TestA_class.java" inpath="code.jar" options="-1.5,-Xreweavable"/> + <run class="TestA_class"/> + </ajc-test> + <ajc-test dir="java5/generics/itds/binaryweaving" vm="1.5" title="binary weaving ITDs - 1"> <compile files="BaseClass.java" outjar="code.jar" options="-1.5,-Xreweavable"/> <compile files="A1.aj" inpath="code.jar" options="-1.5,-Xreweavable"/> <run class="BaseClass"> <stderr> - <line text="Advice from A1 ran successfully"/> + <line text="Advice count=1"/> </stderr> </run> </ajc-test> <ajc-test dir="java5/generics/itds/binaryweaving" vm="1.5" title="binary weaving ITDs - 2"> - <compile files="BaseClass.java,A1.aj" outjar="code.jar" options="-1.5,-Xreweavable"/> - <compile files="A2.aj" inpath="code.jar" options="-1.5,-Xreweavable"/> + <compile files="BaseClass.java,A1.aj" outjar="code.jar" options="-1.5,-Xreweavable,-showWeaveInfo"> + <message kind="weave" text="Type 'BaseClass' (BaseClass.java) has intertyped field from 'A1' (A1.aj:'java.util.List BaseClass.list1')"/> + <message kind="weave" text="Type 'BaseClass' (BaseClass.java:12) advised by after advice from 'A1' (A1.aj:7)"/> + </compile> + <compile files="A2.aj" inpath="code.jar" options="-1.5,-Xreweavable,-showWeaveInfo"> + <message kind="weave" text="Type 'BaseClass' (BaseClass.java) has intertyped field from 'A1' (A1.aj:'java.util.List BaseClass.list1')"/> + <message kind="weave" text="Type 'BaseClass' (BaseClass.java:12) advised by after advice from 'A1' (A1.aj:7)"/> + <message kind="weave" text="Type 'BaseClass' (BaseClass.java) has intertyped field from 'A2' (A2.aj:'java.util.List BaseClass.list2')"/> + <message kind="weave" text="Type 'BaseClass' (BaseClass.java:13) advised by after advice from 'A2' (A2.aj:8)"/> + </compile> <run class="BaseClass"> <stderr> - <line text="Advice from A1 ran successfully"/> - <line text="Advice from A2 ran successfully"/> + <line text="Advice count=2"/> </stderr> </run> </ajc-test> @@ -3042,9 +3318,7 @@ <compile files="A3.aj" inpath="code.jar" options="-1.5,-Xreweavable"/> <run class="BaseClass"> <stderr> - <line text="Advice from A1 ran successfully"/> - <line text="Advice from A2 ran successfully"/> - <line text="Advice from A3 ran successfully"/> + <line text="Advice count=3"/> </stderr> </run> </ajc-test> |