Return types array/list/stream [was: API question for point lambdafication]

Remi Forax forax at univ-mlv.fr
Wed Feb 20 10:30:33 PST 2013


On 02/20/2013 05:10 PM, Tom Hawtin wrote:
> On 20/02/2013 11:17, Remi Forax wrote:
>
>> Most of java.lang uses arrays instead of List to avoid too many
>> dependencies between
>> java.lang and java.util which cause nightmare during the booting
>> sequence of the JDK.
> Like many other packages, java.lang predates the Java2 collection
> framework, so has to use arrays. As practically everything already
> existing is using arrays, it's tricky to mix in collections just for new
> methods. It's a pity as "some things" is a pretty fundamental concept.
> Whereas a mutable, ordered collection of fixed size is an implementation
> detail that should be hidden away.
>
> Dependency between packages does not fundamentally cause problems with
> start up. It's dependency between individual classes, irrespective of
> arbitrary package, which is important.

yes, but classes of a same package tends to depend on classes of the 
same package.
As an example, when you call Collections.emptyList() you ask to run the 
static init block that initializes EMPTY_LIST, EMPTY_SET and EMPTY_MAP 
that loads AbstractCollection, AbtractList, AbstractSet, AbstractMap etc.

>
> (It may be worth mentioning that implementation of fundamental types may
> be surprisingly complicated. For instance, HashMap currently does a lot
> of work to find a random number for some strange purpose.)

or java.util.Local that loads a dozen classes of java.util.concurrent :(

>
> Tom
>

Rémi



More information about the lambda-dev mailing list