On 6 June 2011 22:47, Jörg Schaible <joerg.schai...@gmx.de> wrote:
> sebb wrote:
>
>> On 6 June 2011 09:24, Gump <iss...@commons.apache.org> wrote:
>>> To whom it may engage...
>>>
>>> This is an automated request, but not an unsolicited one. For
>>> more information please visit http://gump.apache.org/nagged.html,
>>> and/or contact the folk at gene...@gump.apache.org.
>>>
>>> Project commons-lang3 has an issue affecting its community integration.
>>> This issue affects 1 projects.
>>> The current state of this project is 'Failed', with reason 'Build
>>> Failed'. For reference only, the following projects are affected by this:
>>> - commons-lang3 :  utilities for the classes that are in java.lang's
>>> hierarchy
>>
>> Oops - that was caused by my fixes for the Eclipse warnings about
>> varargs invocatiions.
>> Only the (Class<?>[]) casts work. I'll fix up the errors shortly.
>
> You could have done this:
>
> ================= %< ================
> -        assertNull("null -> null",
> ClassUtils.primitivesToWrappers((Class<?>[]) null)); // test both types of
> ...
> -        assertNull("null -> null",
> ClassUtils.primitivesToWrappers((Class<?>) null));   // ... varargs
> invocation
> +        assertNull("null -> null", ClassUtils.primitivesToWrappers());

Fails, see below.

> +        assertNull("null -> null",
> ClassUtils.primitivesToWrappers((Class<?>[]) null)); // explicit cast to
> avoid warning

I was trying to fix the warning generated by the following code:

assertNull("null -> null", ClassUtils.primitivesToWrappers(null));

i.e.

"The argument of type null should explicitly be cast to Class<?>[] for
the invocation of the varargs method primitivesToWrappers(Class<?>...)
from type ClassUtils. It could alternatively be cast to Class<?> for a
varargs invocation"

There are several ways to call the varargs method with a null parameter:

1) ClassUtils.primitivesToWrappers(null); // generates the warning
2) ClassUtils.primitivesToWrappers((Class<?>[]) null);
3) ClassUtils.primitivesToWrappers((Class<?>) null);
4) ClassUtils.primitivesToWrappers(); // no parameter

1) and 2) both result in passing a null parameter to the method, so
that is why I eventually chose to replace 1) by 2)

3) is equivalent to

ClassUtils.primitivesToWrappers(new Class<?>[]{null}); // i.e array
length 1 containing null

4) is equivalent to

ClassUtils.primitivesToWrappers(new Class<?>[0]); // empty array
or equally
ClassUtils.primitivesToWrappers(new Class<?>[]{}); // empty array

AFAICT, neither of these are currently tested; they probably should be.

Now the Javadoc says that an empty array is returned as an empty
array, so the following fails:

assertNull("null -> null", ClassUtils.primitivesToWrappers());

The following succeeds:

assertTrue("empty -> empty",
Arrays.equals(ArrayUtils.EMPTY_CLASS_ARRAY,
ClassUtils.primitivesToWrappers()));

> ================= %< ================
>
> - Jörg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
> For additional commands, e-mail: dev-h...@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to