You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for (VariableElement field : new HashSet<>(fieldElts)) {
field.toString(); // error with JDK 8, not JDK 11
}
The above code issues an error with JDK 8, but not JDK 11. See the full test case below. I suspect it is because JDK 8 annotations are from classf iles, but JDK 11 annotations are from stub files.
import java.util.AbstractSet;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.VariableElement;
public class HashSetTest {
void method(Set<VariableElement> fieldElts) {
for (VariableElement field : new MySet<>(fieldElts)) {
field.toString(); // ok with both JDK 8 and JDK 11
}
for (VariableElement field : new HashSet<>(fieldElts)) {
field.toString(); // error with JDK 8, not JDK 11
}
}
static class MySet<E> extends AbstractSet<E> {
public MySet(Collection<? extends E> other) { }
@Override
public Iterator<E> iterator() {
throw new RuntimeException();
}
@Override
public int size() {
return 0;
}
}
}
The text was updated successfully, but these errors were encountered:
The above code issues an error with JDK 8, but not JDK 11. See the full test case below. I suspect it is because JDK 8 annotations are from classf iles, but JDK 11 annotations are from stub files.
The text was updated successfully, but these errors were encountered: