JEP 186: Collection Literals

Remi Forax forax at univ-mlv.fr
Wed Jan 15 09:47:30 PST 2014


On 01/15/2014 06:28 PM, Per Bothner wrote:
> On 01/15/2014 09:14 AM, Remi Forax wrote:
>> On 01/15/2014 06:04 PM, Per Bothner wrote:
>>> (1) Target-typing means you don't have to redundantly specify T:
>>>
>>> T v = { e1, ..., en};
>>>
>>> vs
>>>
>>> T v = T.of(e1, ..., en);
>>>
>>> (2) Using the T.of form requires allocating an array,
>>> which is then thrown away.
>>>
>>
>> I disagree for (1),
>
> You mean (2), presumably.

yes, sorry.

>
>> if you take a look to java.util.EnumSet by example,
>> you will see that there are multiple overloads of 'of' to avoid to 
>> allocate
>> an array in the common cases.
>
> For EnumSet, the short cases are probably the common cases.
> That doesn't help for lists that are longer than some small number.
>
> However, I don't consider this a major motivation.  If performance
> is a factor, it should be possible for the VM to special-case
> the argument-passing.  Certainly for common well-known classes.

special casing argument passing is a piece of code you don't want to 
change in Hotspot,
a lot of codes rely on that, there are 3 conventions of call 
(interpreter, c1, c2)
multiplied by the 5 ways of doing an invoke*.

Rémi






More information about the lambda-dev mailing list