42 ExpectedGenericString egs = method.getAnnotation(ExpectedGenericString.class); |
42 ExpectedGenericString egs = method.getAnnotation(ExpectedGenericString.class); |
43 if (egs != null) { |
43 if (egs != null) { |
44 String actual = method.toGenericString(); |
44 String actual = method.toGenericString(); |
45 System.out.println(actual); |
45 System.out.println(actual); |
46 if (method.isBridge()) { |
46 if (method.isBridge()) { |
47 if (! egs.bridgeValue().equals(actual)) { |
47 failures += checkForFailure(egs.bridgeValue(), actual); |
48 failures++; |
|
49 System.err.printf("ERROR: Expected ''%s''; got ''%s''.\n", |
|
50 egs.value(), actual); |
|
51 } |
|
52 } else { |
48 } else { |
53 if (! egs.value().equals(actual)) { |
49 failures += checkForFailure(egs.value(), actual); |
54 failures++; |
|
55 System.err.printf("ERROR: Expected ''%s''; got ''%s''.\n", |
|
56 egs.value(), actual); |
|
57 } |
|
58 } |
50 } |
59 } |
51 } |
60 |
52 |
61 if (method.isAnnotationPresent(ExpectedString.class)) { |
53 if (method.isAnnotationPresent(ExpectedString.class)) { |
62 ExpectedString es = method.getAnnotation(ExpectedString.class); |
54 ExpectedString es = method.getAnnotation(ExpectedString.class); |
63 String actual = method.toString(); |
55 String actual = method.toString(); |
64 if (! es.value().equals(actual)) { |
56 failures += checkForFailure(es.value(), actual); |
65 failures++; |
|
66 System.err.printf("ERROR: Expected ''%s''; got ''%s''.\n", |
|
67 es.value(), actual); |
|
68 } |
|
69 } |
57 } |
70 |
58 |
71 } |
59 } |
72 |
60 |
73 // Bridge Test; no "volatile" methods |
61 // Bridge Test; no "volatile" methods |
85 |
73 |
86 if (failures > 0) { |
74 if (failures > 0) { |
87 System.err.println("Test failed."); |
75 System.err.println("Test failed."); |
88 throw new RuntimeException(); |
76 throw new RuntimeException(); |
89 } |
77 } |
|
78 } |
|
79 |
|
80 private static int checkForFailure(String expected, String actual) { |
|
81 if (!expected.equals(actual)) { |
|
82 System.err.printf("ERROR: Expected ''%s'';%ngot ''%s''.\n", |
|
83 expected, actual); |
|
84 return 1; |
|
85 } else |
|
86 return 0; |
90 } |
87 } |
91 } |
88 } |
92 |
89 |
93 class TestClass1 { |
90 class TestClass1 { |
94 @ExpectedGenericString( |
91 @ExpectedGenericString( |
113 "public <T> T TestClass2.method1(E,T)") |
110 "public <T> T TestClass2.method1(E,T)") |
114 public <T> T method1(E e, T t) {return null;} |
111 public <T> T method1(E e, T t) {return null;} |
115 |
112 |
116 @ExpectedGenericString( |
113 @ExpectedGenericString( |
117 "public void TestClass2.method2() throws F") |
114 "public void TestClass2.method2() throws F") |
|
115 @ExpectedString( |
|
116 "public void TestClass2.method2() throws java.lang.Exception") |
118 public void method2() throws F {return;} |
117 public void method2() throws F {return;} |
119 |
118 |
120 @ExpectedGenericString( |
119 @ExpectedGenericString( |
121 "public E[] TestClass2.method3()") |
120 "public E[] TestClass2.method3()") |
122 public E[] method3() {return null;} |
121 public E[] method3() {return null;} |