Sized (original) (raw)

Brian Goetz brian.goetz at oracle.com
Fri Nov 2 15:05:33 PDT 2012


We've been using a placeholder interface Sized in the Streams API, for two reasons:

Here's how this migration story might work. Today, we have:

interface Sized { int size(); default long longSize() { return size(); } }

and add it as a new supertype of Collection.

Then (now or later) we can add a subtype:

interface LongSized extends Sized { default int size() { long size = longSize(); if (size > Integer.MAX_VALUE) throw something; return (int) size; }

 long longSize(); // reabstraction

}

Then, 64-bit-aware collections can implement LongSized.



More information about the lambda-libs-spec-observers mailing list