Document some @SuppressWarning annotations

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1391003 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastian Bazley 2012-09-27 13:34:33 +00:00
parent 76833dc4a4
commit cc730589cd
4 changed files with 6 additions and 8 deletions

View File

@ -73,8 +73,7 @@ public class AnnotationUtils {
Class<? extends Annotation> annotationType = null; Class<? extends Annotation> annotationType = null;
for (Class<?> iface : ClassUtils.getAllInterfaces(cls)) { for (Class<?> iface : ClassUtils.getAllInterfaces(cls)) {
if (Annotation.class.isAssignableFrom(iface)) { if (Annotation.class.isAssignableFrom(iface)) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked") // OK because we just checked the assignability
//because we just checked the assignability
Class<? extends Annotation> found = (Class<? extends Annotation>) iface; Class<? extends Annotation> found = (Class<? extends Annotation>) iface;
annotationType = found; annotationType = found;
break; break;

View File

@ -4961,8 +4961,7 @@ public class ArrayUtils {
* (index < 0 || index >= array.length), or if the array is {@code null}. * (index < 0 || index >= array.length), or if the array is {@code null}.
* @since 3.0.1 * @since 3.0.1
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked") // removeAll() always creates an array of the same type as its input
// removeAll() always creates an array of the same type as its input
public static <T> T[] removeAll(T[] array, int... indices) { public static <T> T[] removeAll(T[] array, int... indices) {
return (T[]) removeAll((Object) array, clone(indices)); return (T[]) removeAll((Object) array, clone(indices));
} }

View File

@ -536,7 +536,7 @@ public class ObjectUtils {
+ obj.getClass().getName(), e.getCause()); + obj.getClass().getName(), e.getCause());
} }
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked") // OK because input is of type T
final T checked = (T) result; final T checked = (T) result;
return checked; return checked;
} }

View File

@ -245,12 +245,12 @@ public class EventListenerSupport<L> implements Serializable {
* @throws ClassNotFoundException if the class cannot be resolved * @throws ClassNotFoundException if the class cannot be resolved
*/ */
private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException { private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked") // Will throw CCE here if not correct
L[] listeners = (L[]) objectInputStream.readObject(); L[] listeners = (L[]) objectInputStream.readObject();
this.listeners = new CopyOnWriteArrayList<L>(listeners); this.listeners = new CopyOnWriteArrayList<L>(listeners);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked") // Will throw CCE here if not correct
Class<L> listenerInterface = (Class<L>) listeners.getClass().getComponentType(); Class<L> listenerInterface = (Class<L>) listeners.getClass().getComponentType();
initializeTransientFields(listenerInterface, Thread.currentThread().getContextClassLoader()); initializeTransientFields(listenerInterface, Thread.currentThread().getContextClassLoader());
@ -262,7 +262,7 @@ public class EventListenerSupport<L> implements Serializable {
* @param classLoader the class loader to be used * @param classLoader the class loader to be used
*/ */
private void initializeTransientFields(Class<L> listenerInterface, ClassLoader classLoader) { private void initializeTransientFields(Class<L> listenerInterface, ClassLoader classLoader) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked") // Will throw CCE here if not correct
L[] array = (L[]) Array.newInstance(listenerInterface, 0); L[] array = (L[]) Array.newInstance(listenerInterface, 0);
this.prototypeArray = array; this.prototypeArray = array;
createProxy(listenerInterface, classLoader); createProxy(listenerInterface, classLoader);