-// 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");
}
}
// 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> {
public static void main(String []argv) {
Util.dumpMethods("D");
}
-}
\ No newline at end of file
+}
// 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 static void main(String []argv) {
Util.dumpMethods("D");
}
-}
\ No newline at end of file
+}
-// 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 {
}
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");
+ }
+}
// 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> {
}
class D extends C<String> {
- //String next() {return "";}
+ //public String next() {return "";}
}
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();
}
}
--- /dev/null
+// 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");
+ }
+}
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);
} 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) {
}
return sb.toString();
}
-}
\ No newline at end of file
+}
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");
}
}
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
+}
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");
}
}
public void testAtOverride7() {runTest("atOverride used with ITDs - 7");}
- // bridge methods
-// public void testITDBridgeMethodsCovariance1() {runTest("bridging with covariance 1 normal");}
-// public void testITDBridgeMethodsCovariance2() {runTest("bridging with covariance 1 itd");}
-// public void testITDBridgeMethodsCovariance3() {runTest("bridging with covariance 1 itd binary weaving");}
-// public void testITDBridgeMethods1Normal() {runTest("basic bridging with type vars - 1 - normal");}
-// public void testITDBridgeMethods1Itd() {runTest("basic bridging with type vars - 1 - itd");}
-// public void testITDBridgeMethods2() {runTest("basic bridging with type vars - 2");}
-// public void testITDBridgeMethodsPr91381() {runTest("Abstract intertype method and covariant returns");}
-
- public void testGenericITDsBridgeMethods1() {runTest("bridge methods -1");}
-// public void testGenericITDsBridgeMethods1binary() {runTest("bridge methods -1binary");}
- public void testGenericITDsBridgeMethods2() {runTest("bridge methods -2");}
-// public void testGenericITDsBridgeMethods2binary() {runTest("bridge methods -2binary");}
- public void testGenericITDsBridgeMethods3() {runTest("bridge methods -3");}
-// public void testGenericITDsBridgeMethods3binary() {runTest("bridge methods -3binary");}
+ // bridge methods
+ public void testITDBridgeMethodsCovariance1() {runTest("bridging with covariance 1 - normal");}
+ public void testITDBridgeMethodsCovariance2() {runTest("bridging with covariance 1 - itd");}
+ public void testITDBridgeMethods1Normal() {runTest("basic bridging with type vars - 1 - normal");}
+ public void testITDBridgeMethods1Itd() {runTest("basic bridging with type vars - 1 - itd");}
+ public void testITDBridgeMethods2Normal() {runTest("basic bridging with type vars - 2 - normal");}
+ public void testITDBridgeMethods2Itd() {runTest("basic bridging with type vars - 2 - itd");}
+ public void testITDBridgeMethodsPr91381() {runTest("Abstract intertype method and covariant returns");}
+
+ public void testGenericITDsBridgeMethods1() {runTest("bridge methods - 1");}
+ public void testGenericITDsBridgeMethods1binary() {runTest("bridge methods - 1 - binary");}
+ public void testGenericITDsBridgeMethods2() {runTest("bridge methods - 2");}
+// public void testGenericITDsBridgeMethods2binary() {runTest("bridge methods - 2 - binary");} // pr108101
+ public void testGenericITDsBridgeMethods3() {runTest("bridge methods - 3");}
+// public void testGenericITDsBridgeMethods3binary() {runTest("bridge methods - 3 - binary");} // pr108101
public void testGenericITDsBridgeMethodsPR91381() {runTest("abstract intertype methods and covariant returns");}
public void testGenericITDsBridgeMethodsPR91381_2() {runTest("abstract intertype methods and covariant returns - error");}
<!-- generics/itds and bridge methods -->
- <ajc-test dir="java5/generics/itds/bridgeMethods" vm="1.5" title="bridge methods -1">
+ <ajc-test dir="java5/generics/itds/bridgeMethods" vm="1.5" title="bridge methods - 1">
<compile files="Sub1.java,Super1.java,X1.aj,Util.java" options="-1.5"/>
- <run class="X1"/>
+ <run class="X1">
+ <stderr>
+ <line text="Number of methods defined for Sub1 is 2"/>
+ <line text="java.lang.Integer Sub1.m()"/>
+ <line text="java.lang.Object Sub1.m() [BridgeMethod]"/>
+ </stderr>
+ </run>
</ajc-test>
- <ajc-test dir="java5/generics/itds/bridgeMethods" vm="1.5" title="bridge methods -1binary">
+
+ <ajc-test dir="java5/generics/itds/bridgeMethods" vm="1.5" title="bridge methods - 1 - binary">
<compile files="Sub1.java,Super1.java" outjar="code.jar" options="-1.5"/>
<compile files="X1.aj,Util.java" inpath="code.jar" options ="-1.5"/>
- <run class="X1"/>
+ <run class="X1">
+ <stderr>
+ <line text="Number of methods defined for Sub1 is 2"/>
+ <line text="java.lang.Integer Sub1.m()"/>
+ <line text="java.lang.Object Sub1.m() [BridgeMethod]"/>
+ </stderr>
+ </run>
</ajc-test>
- <ajc-test dir="java5/generics/itds/bridgeMethods" vm="1.5" title="bridge methods -2">
+ <ajc-test dir="java5/generics/itds/bridgeMethods" vm="1.5" title="bridge methods - 2">
<compile files="Sub2.java,Super2.java,X2.aj,Util.java" options="-1.5"/>
- <run class="X2"/>
+ <run class="X2">
+ <stderr>
+ <line text="Number of methods defined for Sub2 is 2"/>
+ <line text="java.lang.Integer Sub2.m()"/>
+ <line text="java.lang.Object Sub2.m() [BridgeMethod]"/>
+ </stderr>
+ </run>
</ajc-test>
- <ajc-test dir="java5/generics/itds/bridgeMethods" vm="1.5" title="bridge methods -2binary">
+ <ajc-test dir="java5/generics/itds/bridgeMethods" vm="1.5" title="bridge methods - 2 - binary">
<compile files="Sub2.java,Super2.java" outjar="code.jar" options="-1.5"/>
<compile files="X2.aj,Util.java" inpath="code.jar" options ="-1.5"/>
- <run class="X2"/>
+ <run class="X2">
+ <stderr>
+ <line text="Number of methods defined for Sub2 is 2"/>
+ <line text="java.lang.Integer Sub2.m()"/>
+ <line text="java.lang.Object Sub2.m() [BridgeMethod]"/>
+ </stderr>
+ </run>
</ajc-test>
- <ajc-test dir="java5/generics/itds/bridgeMethods" vm="1.5" title="bridge methods -3">
+ <ajc-test dir="java5/generics/itds/bridgeMethods" vm="1.5" title="bridge methods - 3">
<compile files="Sub3.java,Super3.java,X3.aj,Util.java" options="-1.5"/>
- <run class="X3"/>
+ <run class="X3">
+ <stderr>
+ <line text="Number of methods defined for Sub3 is 2"/>
+ <line text="java.lang.Integer Sub3.m()"/>
+ <line text="java.lang.Object Sub3.m() [BridgeMethod]"/>
+ </stderr>
+ </run>
</ajc-test>
- <ajc-test dir="java5/generics/itds/bridgeMethods" vm="1.5" title="bridge methods -3binary">
+
+ <ajc-test dir="java5/generics/itds/bridgeMethods" vm="1.5" title="bridge methods - 3 - binary">
<compile files="Sub3.java,Super3.java" outjar="code.jar" options="-1.5"/>
<compile files="X3.aj,Util.java" inpath="code.jar" options ="-1.5"/>
- <run class="X3"/>
+ <run class="X3">
+ <stderr>
+ <line text="Number of methods defined for Sub3 is 2"/>
+ <line text="java.lang.Integer Sub3.m()"/>
+ <line text="java.lang.Object Sub3.m() [BridgeMethod]"/>
+ </stderr>
+ </run>
</ajc-test>
<ajc-test dir="java5/generics/itds/bridgeMethods" vm="1.5" title="abstract intertype methods and covariant returns">
</ajc-test>
- <ajc-test dir="java5/generics/itds/bridgeMethods" vm="1.5" title="bridging with covariance 1 normal">
+ <ajc-test dir="java5/generics/itds/bridgeMethods" vm="1.5" title="bridging with covariance 1 - normal">
<compile files="Bridging1.aj,Util.java" options="-1.5"/>
- <run class="Bridging1"/>
- </ajc-test>
- <ajc-test dir="java5/generics/itds/bridgeMethods" vm="1.5" title="bridging with covariance 1 itd">
+ <run class="Bridging1">
+ <stderr>
+ <line text="Number of methods defined for D is 2"/>
+ <line text="C D.method1() [BridgeMethod]"/>
+ <line text="D D.method1()"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="java5/generics/itds/bridgeMethods" vm="1.5" title="bridging with covariance 1 - itd">
<compile files="BridgingITD1.aj,Util.java" options="-1.5"/>
- <run class="BridgingITD1"/>
+ <run class="BridgingITD1">
+ <stderr>
+ <line text="Number of methods defined for D is 2"/>
+ <line text="C D.method1() [BridgeMethod]"/>
+ <line text="D D.method1()"/>
+ </stderr>
+ </run>
</ajc-test>
<ajc-test dir="java5/generics/itds/bridgeMethods" vm="1.5" title="basic bridging with type vars - 1 - normal">
</run>
</ajc-test>
- <ajc-test dir="java5/generics/itds/bridgeMethods" vm="1.5" title="basic bridging with type vars - 2">
+ <ajc-test dir="java5/generics/itds/bridgeMethods" vm="1.5" title="basic bridging with type vars - 2 - normal">
<compile files="Bridging3.aj,Util.java" options="-1.5"/>
<run class="Bridging3">
<stderr>
</run>
</ajc-test>
+ <ajc-test dir="java5/generics/itds/bridgeMethods" vm="1.5" title="basic bridging with type vars - 2 - itd">
+ <compile files="BridgingITD3.aj,Util.java" options="-1.5"/>
+ <run class="BridgingITD3">
+ <stderr>
+ <line text="Number of methods defined for D is 2"/>
+ <line text="java.lang.Object D.id(java.lang.Object) [BridgeMethod]"/>
+ <line text="java.lang.String D.id(java.lang.String)"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
<ajc-test dir="java5/generics/itds/bridgeMethods" vm="1.5" title="Abstract intertype method and covariant returns" pr="91381">
<compile files="pr91381.aj" options="-1.5,-showWeaveInfo">
<message kind="weave" text="Type 'A' (pr91381.aj) has intertyped method from 'pr91381' (pr91381.aj:'java.lang.Object A.foo()')"/>