RFR: 8023275: Wrapping collections should override default methods

Paul Sandoz paul.sandoz at oracle.com
Tue Aug 20 09:21:03 UTC 2013


[resending unsigned, sorry if a dup arrives later on]

On Aug 19, 2013, at 9:18 PM, Henry Jen <henry.jen at oracle.com> wrote:

> Hi,
> 
> Please review the webrev at
> http://cr.openjdk.java.net/~henryjen/tl/8023275/0/webrev/
> 
> The patch adds override on default methods for a couple wrapping classed
> and delegate those to underlying class.
> 
> There is a minor revise on synchronizedCollection javadoc to cover Stream.
> 

Looks good.


> A sanity check on wrapper classes to ensure default methods are override.
> 

You might want to additionally use an ArrayList instance for unmodifiableList/synchronizedList/checkedList, so as to check both unmod list impls:

   public static <T> List<T> unmodifiableList(List<? extends T> list) {
       return (list instanceof RandomAccess ?
               new UnmodifiableRandomAccessList<>(list) :
               new UnmodifiableList<>(list));
   }

Paul.



More information about the core-libs-dev mailing list