RFR: 8001647: In-place methods on Collection/List

Alan Bateman Alan.Bateman at oracle.com
Mon Dec 10 13:28:11 UTC 2012

On 08/12/2012 01:42, Akhil Arora wrote:
> As part of the Library Lambdafication, this patch adds the following
> default methods to Collections -
> Iterable.forEach(Block<T>)
> Collection.removeAll(Predicate<T>)
> List.sort(Comparator)
> List.replaceAll(UnaryOperator<T>)
> It also provides more efficient implementations of these methods for
> ArrayList, Vector and CopyOnWriteArrayList. Please review.
> http://cr.openjdk.java.net/~akhil/8001647.1/webrev/
> Thanks to the many people who have already contributed to this patch.
This may be bikeshed territory but we usually don't use the "public" 
modifier on methods defined by interfaces as they are public anyway. It 
seems inconsistent to me to have it on the default methods. Perhaps this 
has been discussed before, in which case ignore this. BTW: The only 
reason I'm bringing this up is because there are lots of default methods 
to come and it would be nice to establish a convention and consistency 
from the start.

One small comment on ArrayList.removeAll is that it might be more 
efficient to keep a count of the number of elements to remove rather 
than using the cardinality method (to avoid the bit scan).

For the supporting classes in testlibrary then is @library needed? (I 
haven't fully groked how jtreg supports TestNG so perhaps @library 
without specifying a location or JAR file has some meaning).


More information about the core-libs-dev mailing list