Skip to content

Commit 2eca17d

Browse files
asotonaVicente Romero
authored and
Vicente Romero
committedFeb 25, 2021
8261457: test/langtools/tools/javac/T8187978 can fail if ArrayList class is modified
Reviewed-by: vromero
1 parent c54724d commit 2eca17d

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed
 

‎test/langtools/tools/javac/T8187978/FilterOutCandidatesForDiagnosticsTest.java

+42-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,50 @@
55
* @compile/fail/ref=FilterOutCandidatesForDiagnosticsTest.out -XDrawDiagnostics FilterOutCandidatesForDiagnosticsTest.java
66
*/
77

8-
import java.util.*;
9-
108
class FilterOutCandidatesForDiagnosticsTest {
9+
10+
interface C<E> {
11+
boolean add(E e);
12+
}
13+
14+
interface L<E> extends C<E> {
15+
@Override
16+
boolean add(E e);
17+
void add(int index, E element);
18+
}
19+
20+
static abstract class AC<E> implements C<E> {
21+
@Override
22+
public boolean add(E e) {
23+
throw new UnsupportedOperationException();
24+
}
25+
}
26+
27+
static abstract class AL<E> extends AC<E> implements L<E> {
28+
@Override
29+
public boolean add(E e) {
30+
return true;
31+
}
32+
@Override
33+
public void add(int index, E element) {
34+
throw new UnsupportedOperationException();
35+
}
36+
}
37+
38+
static class ARL<E> extends AL<E> implements L<E> {
39+
@Override
40+
public boolean add(E e) {
41+
throw new UnsupportedOperationException();
42+
}
43+
@Override
44+
public void add(int index, E element) {
45+
}
46+
private void add(E e, Object[] elementData, int s) {
47+
}
48+
}
49+
1150
void test() {
12-
make(new ArrayList<String>(), new ArrayList<Integer>()).add("");
51+
make(new ARL<String>(), new ARL<Integer>()).add("");
1352
}
1453

1554
<Z> Z make(Z z1, Z z2) {
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
FilterOutCandidatesForDiagnosticsTest.java:12:64: compiler.err.cant.apply.symbols: kindname.method, add, java.lang.String,{(compiler.misc.inapplicable.method: kindname.method, java.util.ArrayList, add(compiler.misc.type.captureof: 1, ? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<?>&java.lang.constant.Constable&java.lang.constant.ConstantDesc>&java.lang.constant.Constable&java.lang.constant.ConstantDesc,java.lang.Object[],int), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, java.util.ArrayList, add(compiler.misc.type.captureof: 1, ? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<?>&java.lang.constant.Constable&java.lang.constant.ConstantDesc>&java.lang.constant.Constable&java.lang.constant.ConstantDesc), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, compiler.misc.type.captureof: 1, ? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<?>&java.lang.constant.Constable&java.lang.constant.ConstantDesc>&java.lang.constant.Constable&java.lang.constant.ConstantDesc))),(compiler.misc.inapplicable.method: kindname.method, java.util.ArrayList, add(int,compiler.misc.type.captureof: 1, ? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<?>&java.lang.constant.Constable&java.lang.constant.ConstantDesc>&java.lang.constant.Constable&java.lang.constant.ConstantDesc), (compiler.misc.arg.length.mismatch))}
1+
FilterOutCandidatesForDiagnosticsTest.java:51:52: compiler.err.cant.apply.symbols: kindname.method, add, java.lang.String,{(compiler.misc.inapplicable.method: kindname.method, FilterOutCandidatesForDiagnosticsTest.ARL, add(compiler.misc.type.captureof: 1, ? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<?>&java.lang.constant.Constable&java.lang.constant.ConstantDesc>&java.lang.constant.Constable&java.lang.constant.ConstantDesc), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, compiler.misc.type.captureof: 1, ? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<?>&java.lang.constant.Constable&java.lang.constant.ConstantDesc>&java.lang.constant.Constable&java.lang.constant.ConstantDesc))),(compiler.misc.inapplicable.method: kindname.method, FilterOutCandidatesForDiagnosticsTest.ARL, add(int,compiler.misc.type.captureof: 1, ? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<?>&java.lang.constant.Constable&java.lang.constant.ConstantDesc>&java.lang.constant.Constable&java.lang.constant.ConstantDesc), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, FilterOutCandidatesForDiagnosticsTest.ARL, add(compiler.misc.type.captureof: 1, ? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<?>&java.lang.constant.Constable&java.lang.constant.ConstantDesc>&java.lang.constant.Constable&java.lang.constant.ConstantDesc,java.lang.Object[],int), (compiler.misc.arg.length.mismatch))}
22
1 error

0 commit comments

Comments
 (0)
Please sign in to comment.