commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simone Tripodi <simonetrip...@apache.org>
Subject Re: svn commit: r1449929 - /commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/AbstractMapBag.java
Date Tue, 26 Feb 2013 06:57:01 GMT
Hi Thomas,

> +    @SuppressWarnings("unchecked")
>      public <T> T[] toArray(T[] array) {
>          final int size = size();
>          if (array.length < size) {
> -            // This is safe, both are type T
>              array = (T[]) Array.newInstance(array.getClass().getComponentType(), size);
>          }
>
> @@ -466,7 +469,6 @@ public abstract class AbstractMapBag<E>
>          while (it.hasNext()) {
>              final E current = it.next();
>              for (int index = getCount(current); index > 0; index--) {
> -                // TODO this is unsafe
>                  array[i++] = (T) current;
>              }
>          }
>

it is a good practice here commenting why the unchecked warning can be
suppressed - it will definitively help also future maintainers :)

TIA!
-Simo

http://people.apache.org/~simonetripodi/
http://simonetripodi.livejournal.com/
http://twitter.com/simonetripodi
http://www.99soft.org/

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


Mime
View raw message