-
Bug
-
Resolution: Fixed
-
P2
-
8
-
b94
-
Verified
Following code executes silently on b88 - NullPointerException is not thrown:
import java.util.PrimitiveIterator;
import java.util.function.Consumer;
import java.util.function.IntConsumer;
public class PrimitiveIteratorForEachRemaining implements PrimitiveIterator.OfInt {
public static void main(String argv[]) {
new PrimitiveIteratorForEachRemaining().forEachRemaining((IntConsumer) null);
new PrimitiveIteratorForEachRemaining().forEachRemaining((Consumer<Integer>) null);
}
@Override
public int nextInt() {
return 0;
}
@Override
public boolean hasNext() {
return false;
}
}
Similar thing does happen for both PrimitiveIterator.OfLong and PrimitiveIterator.OfDouble as well.
According to forEachRemaining(IntConsumer) spec NPE should be thrown.
I wonder if spec should specify that NPE is thrown when forEachRemaining(Consumer) is passed a null as a consumer?
The code is attached for your convenience.
import java.util.PrimitiveIterator;
import java.util.function.Consumer;
import java.util.function.IntConsumer;
public class PrimitiveIteratorForEachRemaining implements PrimitiveIterator.OfInt {
public static void main(String argv[]) {
new PrimitiveIteratorForEachRemaining().forEachRemaining((IntConsumer) null);
new PrimitiveIteratorForEachRemaining().forEachRemaining((Consumer<Integer>) null);
}
@Override
public int nextInt() {
return 0;
}
@Override
public boolean hasNext() {
return false;
}
}
Similar thing does happen for both PrimitiveIterator.OfLong and PrimitiveIterator.OfDouble as well.
According to forEachRemaining(IntConsumer) spec NPE should be thrown.
I wonder if spec should specify that NPE is thrown when forEachRemaining(Consumer) is passed a null as a consumer?
The code is attached for your convenience.