Code review request for 4881419 The type of X[].clone() should be X[]

Ulf Zibis Ulf.Zibis at gmx.de
Fri Sep 3 22:31:11 UTC 2010


  Am 04.09.2010 00:05, schrieb Joe Darcy:
> Ulf Zibis wrote:
>> Am 03.09.2010 12:31, schrieb Ulf Zibis:
>>>
>>> I think the question of variable types belongs to the spec, but here in Object class's javadoc 
>>> we should speak about objects. So I now suggest:
>>> "...and that the returned object of the {@code clone} method of an array object of class {@code 
>>> T[]} is of class {@code T[]} where T is any [raw]? reference or primitive class. See java 
>>> language specification version 3, section 6.4.5"
>>>
>>
>> And additionally 2 cents: As T is often used for parameter type in context with generics, I 
>> think, X would leed to less misinterpretation and would match better to the according spec.
>>
>
> I think the text as suggested by Martin with the explicit definition of T is sufficiently clear 
> as-is.
>
> -Joe

I still think, it would be more clear to speak about classes here rather then about types.
See:
         Number[] na = new Integer[123];
         na[0] = new Integer(456);
         Integer[] ia = (Integer[])na.clone();

na is of type Number[]
ia is of type Integer[] and too of type Number[]
but ia contains object of class Integer[]

-Ulf







More information about the core-libs-dev mailing list