diff options
author | aclement <aclement> | 2005-10-19 09:04:38 +0000 |
---|---|---|
committer | aclement <aclement> | 2005-10-19 09:04:38 +0000 |
commit | b8915a4c9647f6021578adba01a2532ec23f1148 (patch) | |
tree | d0141231aba000fd461119cff96acadaf0f7e718 /tests/java5 | |
parent | abac6583b34ca2f34ad7c08717fea228c35709f3 (diff) | |
download | aspectj-b8915a4c9647f6021578adba01a2532ec23f1148.tar.gz aspectj-b8915a4c9647f6021578adba01a2532ec23f1148.zip |
generics tests revisted post all the recent changes - more of them now pass!
Diffstat (limited to 'tests/java5')
10 files changed, 67 insertions, 43 deletions
diff --git a/tests/java5/generics/itds/bridgeMethods/Bridging1.aj b/tests/java5/generics/itds/bridgeMethods/Bridging1.aj index 6aefd137e..9aa9f4cf3 100644 --- a/tests/java5/generics/itds/bridgeMethods/Bridging1.aj +++ b/tests/java5/generics/itds/bridgeMethods/Bridging1.aj @@ -1,17 +1,19 @@ -// this bridge stuff is handled by the compiler - because D is a subtype of C even though method1 is being overridden, -// a bridge method 'C method1() { method1();}' is generated in the subclass D +// This bridge stuff is handled by the compiler - because +// D is a subtype of C even though method1 is being overridden, +// a bridge method 'C method1() { method1();}' is generated +// in the subclass D import java.lang.reflect.*; class C { - C method1() {return null;} + C method1() {return null;} } class D extends C { - D method1() {return null;} + D method1() {return null;} } public aspect Bridging1 { public static void main(String []argv) { - Util.dumpMethods("D",new String[]{"C D.method1() [BridgeMethod]","D D.method1()"}); + Util.dumpMethods("D"); } } diff --git a/tests/java5/generics/itds/bridgeMethods/Bridging2.aj b/tests/java5/generics/itds/bridgeMethods/Bridging2.aj index ecd270de3..7a2b6d206 100644 --- a/tests/java5/generics/itds/bridgeMethods/Bridging2.aj +++ b/tests/java5/generics/itds/bridgeMethods/Bridging2.aj @@ -1,4 +1,6 @@ // this bridge stuff is handled by the compiler +// We should get two methods in D, one is next() with return type Object +// and one is next() with return type String import java.lang.reflect.*; abstract class C<A> { @@ -13,4 +15,4 @@ public aspect Bridging2 { public static void main(String []argv) { Util.dumpMethods("D"); } -}
\ No newline at end of file +} diff --git a/tests/java5/generics/itds/bridgeMethods/Bridging3.aj b/tests/java5/generics/itds/bridgeMethods/Bridging3.aj index 13b70034a..0b57f29de 100644 --- a/tests/java5/generics/itds/bridgeMethods/Bridging3.aj +++ b/tests/java5/generics/itds/bridgeMethods/Bridging3.aj @@ -1,4 +1,6 @@ // this bridge stuff is handled by the compiler +// Similar to previous type var test but now the String parameter should +// be Object in the bridge method import java.lang.reflect.*; abstract class C<A> { @@ -13,4 +15,4 @@ public aspect Bridging3 { public static void main(String []argv) { Util.dumpMethods("D"); } -}
\ No newline at end of file +} diff --git a/tests/java5/generics/itds/bridgeMethods/BridgingITD1.aj b/tests/java5/generics/itds/bridgeMethods/BridgingITD1.aj index 8631df618..a2c7df43b 100644 --- a/tests/java5/generics/itds/bridgeMethods/BridgingITD1.aj +++ b/tests/java5/generics/itds/bridgeMethods/BridgingITD1.aj @@ -1,4 +1,5 @@ -// Now the implementation is introduced via an ITD, we should still get the bridge method in the class D +// Now the implementation is introduced via an ITD, we should +// still get the bridge method in the class D import java.lang.reflect.*; class C { @@ -10,8 +11,8 @@ class D extends C { } public aspect BridgingITD1 { - public D D.method1() { return null; } - public static void main(String []argv) { - Util.dumpMethods("D",new String[]{"C D.method1() [BridgeMethod]","D D.method1()"}); - } -}
\ No newline at end of file + public D D.method1() { return null; } + public static void main(String []argv) { + Util.dumpMethods("D"); + } +} diff --git a/tests/java5/generics/itds/bridgeMethods/BridgingITD2.aj b/tests/java5/generics/itds/bridgeMethods/BridgingITD2.aj index 4e1d7b8c9..cc6162e82 100644 --- a/tests/java5/generics/itds/bridgeMethods/BridgingITD2.aj +++ b/tests/java5/generics/itds/bridgeMethods/BridgingITD2.aj @@ -1,4 +1,6 @@ // this bridge stuff is handled by the compiler +// We should get two methods in D, one is next() with return type Object +// and one is next() with return type String import java.lang.reflect.*; abstract class C<A> { @@ -6,7 +8,7 @@ abstract class C<A> { } class D extends C<String> { - //String next() {return "";} + //public String next() {return "";} } public aspect BridgingITD2 { @@ -15,7 +17,7 @@ public aspect BridgingITD2 { public static void main(String []argv) { Util.dumpMethods("D"); - C c = new D(); - String s = c.next(); + D d = new D(); + String s = d.next(); } } diff --git a/tests/java5/generics/itds/bridgeMethods/BridgingITD3.aj b/tests/java5/generics/itds/bridgeMethods/BridgingITD3.aj new file mode 100644 index 000000000..5beff1481 --- /dev/null +++ b/tests/java5/generics/itds/bridgeMethods/BridgingITD3.aj @@ -0,0 +1,19 @@ +// this bridge stuff is handled by the compiler +// Similar to previous type var test but now the String parameter should +// be Object in the bridge method +import java.lang.reflect.*; + +abstract class C<A> { + public abstract A id(A x); +} + +class D extends C<String> { + //public String id(String s) {return s;} +} + +public aspect BridgingITD3 { + public String D.id(String s) {return s;} + public static void main(String []argv) { + Util.dumpMethods("D"); + } +} diff --git a/tests/java5/generics/itds/bridgeMethods/Util.java b/tests/java5/generics/itds/bridgeMethods/Util.java index 1c479defa..cf0b65078 100644 --- a/tests/java5/generics/itds/bridgeMethods/Util.java +++ b/tests/java5/generics/itds/bridgeMethods/Util.java @@ -3,7 +3,7 @@ import java.util.*; public class Util { - public static void checkMethods(String clazzname,String[] expectedMethods) { + public static void dumpMethods(String clazzname) {//,String[] expectedMethods) { List methodsFound = new ArrayList(); try { java.lang.Class clz = Class.forName(clazzname); @@ -20,19 +20,24 @@ public class Util { } catch (Throwable e) {e.printStackTrace();} StringBuffer diagnosticInfo = new StringBuffer(); - diagnosticInfo.append("\nExpected:\n").append(dumparray(expectedMethods)); - diagnosticInfo.append("\nFound:\n").append(dumplist(methodsFound)); - - for (int i = 0; i < expectedMethods.length; i++) { - String string = expectedMethods[i]; - if (!methodsFound.contains(string)) { - throw new RuntimeException("Expecting method '"+string+"' but didnt find it\n"+diagnosticInfo.toString()); - } - methodsFound.remove(string); - } - if (methodsFound.size()>0) { - throw new RuntimeException("Found more methods than expected: "+dumplist(methodsFound)); + Collections.sort(methodsFound); + for (Iterator iter = methodsFound.iterator(); iter.hasNext();) { + String element = (String) iter.next(); + System.err.println(element); } +// diagnosticInfo.append("\nExpected:\n").append(dumparray(expectedMethods)); +// diagnosticInfo.append("\nFound:\n").append(dumplist(methodsFound)); +// +// for (int i = 0; i < expectedMethods.length; i++) { +// String string = expectedMethods[i]; +// if (!methodsFound.contains(string)) { +// throw new RuntimeException("Expecting method '"+string+"' but didnt find it\n"+diagnosticInfo.toString()); +// } +// methodsFound.remove(string); +// } +// if (methodsFound.size()>0) { +// throw new RuntimeException("Found more methods than expected: "+dumplist(methodsFound)); +// } } private static String dumparray(String[] arr) { @@ -63,4 +68,4 @@ public class Util { } return sb.toString(); } -}
\ No newline at end of file +} diff --git a/tests/java5/generics/itds/bridgeMethods/X1.aj b/tests/java5/generics/itds/bridgeMethods/X1.aj index 9ff893ce0..2f085de6a 100644 --- a/tests/java5/generics/itds/bridgeMethods/X1.aj +++ b/tests/java5/generics/itds/bridgeMethods/X1.aj @@ -3,9 +3,6 @@ public aspect X1 { Super1 s = new Sub1(); Integer i = (Integer)s.m(); - Util.checkMethods("Sub1", - new String[]{ - "java.lang.Object Sub1.m() [BridgeMethod]", - "java.lang.Integer Sub1.m()"}); + Util.dumpMethods("Sub1"); } } diff --git a/tests/java5/generics/itds/bridgeMethods/X2.aj b/tests/java5/generics/itds/bridgeMethods/X2.aj index cd9eccffa..ce8f1a542 100644 --- a/tests/java5/generics/itds/bridgeMethods/X2.aj +++ b/tests/java5/generics/itds/bridgeMethods/X2.aj @@ -5,9 +5,6 @@ public aspect X2 { Super2 s = new Sub2(); Integer i = (Integer)s.m(); - Util.checkMethods("Sub2", - new String[]{ - "java.lang.Object Sub2.m() [BridgeMethod]", - "java.lang.Integer Sub2.m()"}); + Util.dumpMethods("Sub2"); } -}
\ No newline at end of file +} diff --git a/tests/java5/generics/itds/bridgeMethods/X3.aj b/tests/java5/generics/itds/bridgeMethods/X3.aj index dc58e33b8..5bd400d10 100644 --- a/tests/java5/generics/itds/bridgeMethods/X3.aj +++ b/tests/java5/generics/itds/bridgeMethods/X3.aj @@ -6,9 +6,6 @@ public aspect X3 { Super3 s = new Sub3(); Integer i = (Integer)s.m(); - Util.checkMethods("Sub3", - new String[]{ - "java.lang.Object Sub3.m() [BridgeMethod]", - "java.lang.Integer Sub3.m()"}); + Util.dumpMethods("Sub3"); } } |