RFR: 8155600 - Performance optimization of Arrays.asList().iterator()
Tagir F. Valeev
amaembo at gmail.com
Fri Apr 29 13:31:27 UTC 2016
Hello!
Thank you for comments. Update:
http://cr.openjdk.java.net/~tvaleev/webrev/8155600/r3/
AS> Test:
AS> *) Formatting: "i=0", "i<array.length", etc should have spaces;
Done.
AS> *) Formatting: "} catch (NSEE ex)" should be on the same line;
Done.
AS> *) What does the "for (int i=0; i<3; i++) {" thing test?
It tests the idempotence of final iterator state: it returns false
from hasNext() and throws from next() no matter how many times you
launch these methods. Sometimes poorly written iterators throw NSEE
only once, then change state somehow and subsequent hasNext()/next()
calls behave differently which violates the contract. For example,
something like this would fail my test:
if (cursor++ == a.length) throw new NoSuchElementException();
AS> *) No need for "parallel = true", should be fine with sequential;
Done.
AS> *) The idiom for exception testing is more self-contained:
AS> try {
AS> itr.next();
AS> fail("Should have thrown NSEE");
AS> } catch (NSEE ex) {
AS> // expected
AS> }
Done.
AS> *) Probably need to add these cases too, to boundary-test the null
AS> handling:
AS> {null}
AS> {null, 1}
AS> {1, null}
AS> {null, null}
AS> {null, 1, 2}
AS> {1, null, 2}
AS> {1, 2, null}
AS> {null, null, null}
Done.
With best regards,
Tagir Valeev.
More information about the core-libs-dev
mailing list