Skip to content

Commit a23155a

Browse files
Adjust GenericTypeTest based on run.javac comparison & own reasoning
+ in some cases reduce expected errors to those expected also by javac + remove unused excuses run.javac score of this test class: 1.8: 7 fails, previously 8 9: 10 fails, previously 14 26: 13 fails, previously 18
1 parent 8e87917 commit a23155a

2 files changed

Lines changed: 26 additions & 73 deletions

File tree

org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -945,9 +945,6 @@ Excuse excuseFor(JavacCompiler compiler) {
945945
new EclipseHasABug(MismatchType.JavacErrorsEclipseWarnings),
946946
EclipseBug421922 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=421922
947947
new EclipseHasABug(MismatchType.EclipseErrorsJavacNone),
948-
EclipseBug428061 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=428061
949-
new EclipseHasABug(MismatchType.JavacErrorsEclipseNone |
950-
MismatchType.JavacErrorsEclipseWarnings),
951948
EclipseBug510528 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=510528
952949
new EclipseHasABug(MismatchType.JavacErrorsEclipseNone),
953950
EclipseBug531531 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=531531

org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java

Lines changed: 26 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -5279,10 +5279,8 @@ public void test0176() {
52795279
}
52805280
// cast to type variable allowed, can be diagnosed as unnecessary
52815281
public void test0177() {
5282-
Map options = getCompilerOptions();
5283-
runConformTest(
5284-
// test directory preparation
5285-
true /* flush output directory */,
5282+
Runner runner = new Runner();
5283+
runner.testFiles =
52865284
new String[] { /* test files */
52875285
"X.java",
52885286
"public class X <T> {\n" +
@@ -5291,22 +5289,15 @@ public void test0177() {
52915289
" return (T) t;\n" +
52925290
" }\n" +
52935291
"}\n",
5294-
},
5295-
// compiler options
5296-
null /* no class libraries */,
5297-
options /* custom options - happen to be the default not changed by the test suite */,
5298-
// compiler results
5292+
};
5293+
runner.expectedCompilerLog =
52995294
"----------\n" + /* expected compiler log */
53005295
"1. WARNING in X.java (at line 4)\n" +
53015296
" return (T) t;\n" +
53025297
" ^^^^^\n" +
53035298
"Unnecessary cast from T to T\n" +
5304-
"----------\n",
5305-
// runtime results
5306-
null /* do not check output string */,
5307-
null /* do not check error string */,
5308-
// javac options
5309-
JavacTestOptions.Excuse.EclipseHasSomeMoreWarnings /* javac test options */);
5299+
"----------\n";
5300+
runner.runWarningTest();
53105301
}
53115302
// reject instanceof type variable or parameterized type
53125303
public void test0178() {
@@ -6431,10 +6422,8 @@ public void test0216() {
64316422
}
64326423
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=69135 - unnecessary cast operation
64336424
public void test0217() {
6434-
Map customOptions = getCompilerOptions();
6435-
runConformTest(
6436-
// test directory preparation
6437-
true /* flush output directory */,
6425+
Runner runner = new Runner();
6426+
runner.testFiles =
64386427
new String[] { /* test files */
64396428
"X.java",
64406429
"import java.util.ArrayList;\n" +
@@ -6444,22 +6433,17 @@ public void test0217() {
64446433
" String string = (String) l.get(0);\n" +
64456434
" }\n" +
64466435
"}\n",
6447-
},
6448-
// compiler options
6449-
null /* no class libraries */,
6450-
customOptions /* custom options */,
6451-
// compiler results
6436+
};
6437+
runner.expectedCompilerLog =
64526438
"----------\n" + /* expected compiler log */
64536439
"1. WARNING in X.java (at line 5)\n" +
64546440
" String string = (String) l.get(0);\n" +
64556441
" ^^^^^^^^^^^^^^^^^\n" +
64566442
"Unnecessary cast from String to String\n" +
6457-
"----------\n",
6458-
// runtime results
6459-
null /* do not check output string */,
6460-
"java.lang.IndexOutOfBoundsException" /* do not check error string */,
6461-
// javac options
6462-
JavacTestOptions.Excuse.EclipseHasSomeMoreWarnings /* javac test options */);
6443+
"----------\n";
6444+
runner.expectedErrorString =
6445+
"java.lang.IndexOutOfBoundsException";
6446+
runner.runWarningTest();
64636447
}
64646448
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=64154 visibility issue due to invalid use of parameterized binding
64656449
public void test0218() {
@@ -6623,11 +6607,6 @@ public void test0223() {
66236607
" MX<Class> mx2 = new MX<Class>();\n" +
66246608
" ^^^^^\n" +
66256609
"Class is a raw type. References to generic type Class<T> should be parameterized\n" +
6626-
"----------\n" +
6627-
"5. WARNING in X.java (at line 18)\n" +
6628-
" mx1.foo(mx2.get());\n" +
6629-
" ^^^^^^^^^\n" +
6630-
"Type safety: The expression of type Class needs unchecked conversion to conform to Class<? extends Object>\n" +
66316610
"----------\n",
66326611
null,
66336612
true,
@@ -7238,11 +7217,6 @@ public void test0242() {
72387217
"1. WARNING in X.java (at line 8)\n" +
72397218
" final Class<? extends Object> clazz = (Class<? extends Object>) classes.get(\"test\");\n" +
72407219
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
7241-
"Type safety: Unchecked cast from Class to Class<?>\n" +
7242-
"----------\n" +
7243-
"2. WARNING in X.java (at line 8)\n" +
7244-
" final Class<? extends Object> clazz = (Class<? extends Object>) classes.get(\"test\");\n" +
7245-
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
72467220
"Unnecessary cast from Class to Class<?>\n" +
72477221
"----------\n" +
72487222
"3. WARNING in X.java (at line 9)\n" +
@@ -22132,20 +22106,17 @@ public void test0702() {
2213222106
"}\n",
2213322107
},
2213422108
"----------\n" +
22135-
"1. ERROR in X.java (at line 7)\n" +
22136-
" lhs = rhs; // 1\n" +
22137-
" ^^^\n" +
22138-
"Type mismatch: cannot convert from X<X<? extends Object>> to X<X<?>>\n" +
22139-
"----------\n" +
22140-
"2. ERROR in X.java (at line 10)\n" +
22109+
"1. ERROR in X.java (at line 10)\n" +
2214122110
" lhs = rhs; // 2\n" +
2214222111
" ^^^\n" +
22143-
"Type mismatch: cannot convert from X<X<? extends Object>> to X<X<? extends Cloneable>>\n" +
22112+
"Type mismatch: cannot convert from X<X<?>> to X<X<? extends Cloneable>>\n" +
22113+
/* this is reported by javac despite equivalence of ? with ? extends Object, see case // 4
2214422114
"----------\n" +
2214522115
"3. ERROR in X.java (at line 13)\n" +
2214622116
" lhs = rhs; // 3\n" +
2214722117
" ^^^\n" +
2214822118
"Type mismatch: cannot convert from X<X<? extends Object>> to X<X<? extends Runnable>>\n" +
22119+
*/
2214922120
"----------\n" +
2215022121
"4. ERROR in X.java (at line 19)\n" +
2215122122
" lhs = rhs; // 5\n" +
@@ -32404,21 +32375,25 @@ public void test1000() {
3240432375
" ^^\n" +
3240532376
"Type safety: Potential heap pollution via varargs parameter it\n" +
3240632377
"----------\n" +
32378+
/* javac reports (2) & (4), although chain() resolves as Iterator#RAW chain(Iterator<?>[]), where the wildcard is unbounded (bounded by Object)
3240732379
"2. WARNING in X.java (at line 9)\n" +
3240832380
" Iterator<Number> it1 = X.chain(new Iterator[] { l1.iterator(), l2.iterator() });\n" +
3240932381
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
3241032382
"Type safety: Unchecked invocation chain(Iterator[]) of the generic method chain(Iterator<? extends T>...) of type X\n" +
3241132383
"----------\n" +
32384+
*/
3241232385
"3. WARNING in X.java (at line 9)\n" +
3241332386
" Iterator<Number> it1 = X.chain(new Iterator[] { l1.iterator(), l2.iterator() });\n" +
3241432387
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
3241532388
"Type safety: The expression of type Iterator needs unchecked conversion to conform to Iterator<Number>\n" +
3241632389
"----------\n" +
32390+
/*
3241732391
"4. WARNING in X.java (at line 9)\n" +
3241832392
" Iterator<Number> it1 = X.chain(new Iterator[] { l1.iterator(), l2.iterator() });\n" +
3241932393
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
3242032394
"Type safety: The expression of type Iterator[] needs unchecked conversion to conform to Iterator<? extends Object>[]\n" +
3242132395
"----------\n" +
32396+
*/
3242232397
"5. WARNING in X.java (at line 14)\n" +
3242332398
" Iterator<Number> it2 = X.chain(l1.iterator(), l2.iterator());\n" +
3242432399
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
@@ -42193,7 +42168,7 @@ public void test1257() {
4219342168
" static interface Sub<T> extends Foo<T> {\n" +
4219442169
" static XList<Sub<? extends Object>> LIST = asList(ARRAY); \n" +
4219542170
" }\n" +
42196-
" static Sub<? extends Object>[] ARRAY = new Sub[] { };\n" +
42171+
" static Sub<? extends Object>[] ARRAY = new Sub[] { };\n" + // javac reports: warning: [rawtypes] found raw type: Sub
4219742172
" }\n" +
4219842173
"}\n" +
4219942174
"\n" +
@@ -42202,12 +42177,7 @@ public void test1257() {
4220242177
"}\n", // =================
4220342178
},
4220442179
"----------\n" +
42205-
"1. WARNING in X.java (at line 7)\n" +
42206-
" static Sub<? extends Object>[] ARRAY = new Sub[] { };\n" +
42207-
" ^^^^^^^^^^^^^\n" +
42208-
"Type safety: The expression of type X.Foo.Sub[] needs unchecked conversion to conform to X.Foo.Sub<?>[]\n" +
42209-
"----------\n" +
42210-
"2. ERROR in X.java (at line 12)\n" +
42180+
"1. ERROR in X.java (at line 12)\n" +
4221142181
" Zork z;\n" +
4221242182
" ^^^^\n" +
4221342183
"Zork cannot be resolved to a type\n" +
@@ -43863,12 +43833,7 @@ public void test1313() {
4386343833
"}\n", // =================
4386443834
},
4386543835
"----------\n" +
43866-
"1. ERROR in X.java (at line 6)\n" +
43867-
" List<?>[] l2 = new List<? extends Object>[2];\n" +
43868-
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
43869-
"Cannot create a generic array of List<? extends Object>\n" +
43870-
"----------\n" +
43871-
"2. ERROR in X.java (at line 7)\n" +
43836+
"1. ERROR in X.java (at line 7)\n" +
4387243837
" List<? extends Object> l3 = new List<?>[3];\n" +
4387343838
" ^^^^^^^^^^^^^^\n" +
4387443839
"Type mismatch: cannot convert from List<?>[] to List<?>\n" +
@@ -47652,11 +47617,8 @@ public void test1420() {
4765247617
"----------\n");
4765347618
}
4765447619
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=257849
47655-
// FIXME javac8 doesn't find the error
4765647620
public void test1421() {
4765747621
this.runNegativeTest(
47658-
false /* skipJavac */,
47659-
JavacTestOptions.Excuse.JavacCompilesIncorrectSource,
4766047622
new String[] {
4766147623
"X.java", //-----------------------------------------------------------------------
4766247624
"public class X {\n" +
@@ -48994,12 +48956,10 @@ public void test1459() {
4899448956
""); // no specific success output string
4899548957
}
4899648958
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=277643
48997-
// SHOULD FAIL AT 1.8 (18.2.3): The method get(Class<W>, T) in the type Test is not applicable for the arguments (Class<Test.W_Description>, Object)
48998-
// FIXME: javac rejects (correctly? how?), see http://mail.openjdk.java.net/pipermail/lambda-spec-experts/2013-December/000443.html
4899948959
public void test277643() {
4900048960
this.runNegativeTest(
4900148961
false /* skipJavac */,
49002-
JavacTestOptions.EclipseHasABug.EclipseBug428061,
48962+
JavacTestOptions.JavacHasABug.JavacBugFixed_901,
4900348963
new String[] {
4900448964
"Test.java",
4900548965
"public class Test {\n" +
@@ -49092,12 +49052,8 @@ public void test280054() {
4909249052
"----------\n");
4909349053
}
4909449054
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=283306
49095-
// SHOULD FAIL AT 1.8 (18.2.3): The method get(Class<V>, Class<S>) in the type X.L is not applicable for the arguments (Class<V>, Class<X.B>)
49096-
// FIXME: javac rejects (correctly? how?), see http://mail.openjdk.java.net/pipermail/lambda-spec-experts/2013-December/000443.html
4909749055
public void test283306() {
4909849056
this.runNegativeTest(
49099-
false /* skipJavac */,
49100-
JavacTestOptions.EclipseHasABug.EclipseBug428061,
4910149057
new String[] {
4910249058
"Test.java",
4910349059
"public class Test {\n" +

0 commit comments

Comments
 (0)