> it is not safe, and it will throw an ArrayStoreException in this case, > which is documented in the throws clause. >
OK I just read the commit, unless it is documented it is fine for me -Simo http://people.apache.org/~simonetripodi/ http://simonetripodi.livejournal.com/ http://twitter.com/simonetripodi http://www.99soft.org/ On Tue, Feb 26, 2013 at 8:35 AM, Thomas Neidhart <thomas.neidh...@gmail.com> wrote: > On 02/26/2013 07:57 AM, Simone Tripodi wrote: >> 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 :) > > it is not safe, and it will throw an ArrayStoreException in this case, > which is documented in the throws clause. > > This is the same behavior as with all java.util collections. > > Thomas > > --------------------------------------------------------------------- > 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