Skip to content
Permalink
Browse files
8261457: test/langtools/tools/javac/T8187978 can fail if ArrayList cl…
…ass is modified

Reviewed-by: vromero
  • Loading branch information
asotona authored and Vicente Romero committed Feb 25, 2021
1 parent c54724d commit 2eca17d1b1b6535f3424026c536cde8697a4ec5d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
@@ -5,11 +5,50 @@
* @compile/fail/ref=FilterOutCandidatesForDiagnosticsTest.out -XDrawDiagnostics FilterOutCandidatesForDiagnosticsTest.java
*/

import java.util.*;

class FilterOutCandidatesForDiagnosticsTest {

interface C<E> {
boolean add(E e);
}

interface L<E> extends C<E> {
@Override
boolean add(E e);
void add(int index, E element);
}

static abstract class AC<E> implements C<E> {
@Override
public boolean add(E e) {
throw new UnsupportedOperationException();
}
}

static abstract class AL<E> extends AC<E> implements L<E> {
@Override
public boolean add(E e) {
return true;
}
@Override
public void add(int index, E element) {
throw new UnsupportedOperationException();
}
}

static class ARL<E> extends AL<E> implements L<E> {
@Override
public boolean add(E e) {
throw new UnsupportedOperationException();
}
@Override
public void add(int index, E element) {
}
private void add(E e, Object[] elementData, int s) {
}
}

void test() {
make(new ArrayList<String>(), new ArrayList<Integer>()).add("");
make(new ARL<String>(), new ARL<Integer>()).add("");
}

<Z> Z make(Z z1, Z z2) {
@@ -1,2 +1,2 @@
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))}
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))}
1 error

0 comments on commit 2eca17d

Please sign in to comment.