RFR: 5047859 : (reflect) Class.getField can't find String[].length

Joel Borggrén-Franck joel.franck at oracle.com
Wed Aug 28 13:39:34 UTC 2013


Hi Mandy,

Thanks for your comments,

On 2013-08-26, Mandy Chung wrote:
> Joel,
> 
> The spec of the getFields and getDeclaredFields() methods both states this:
> 
>   This method returns an array of length 0 if the class
>   or interface declares no fields, or if this|Class|  object
>   represents a primitive type, an array class, or void.
> 
> The spec of the getDeclaredField() method has this sentence:
> 
>   Note that this method will not reflect the {@code length}
>   field of an array class.
> 
> Your change is okay and it would be good to keep the getField(s)
> and getDeclaredField(s) methods be consistent and states its
> return value "if this|Class|  object represents a primitive type,
> an array class, or void"

I agree the javadoc for the 4 methods should be more uniform. The note
in getDeclaredFields() isn't that good IMHO as for example the term
'array class' in not used in JLS.

I'll be back shortly with an updated webrev.

cheers
/Joel



More information about the core-libs-dev mailing list