// try to invoke the clone method reflectively
try {
clonedCollection = (Collection<E>) collection.getClass().getMethod(
"clone", (Class[]) null).invoke(collection, (Object[]) null);
} catch (IllegalArgumentException ex) {
throw new NestedRuntimeException(ex);
} catch (SecurityException ex) {
throw new NestedRuntimeException(ex);
} catch (IllegalAccessException ex) {
throw new NestedRuntimeException(ex);
} catch (InvocationTargetException ex) {
throw new NestedRuntimeException(ex);
} catch (NoSuchMethodException ex) {
// Do nothing. the method simply does not exist.
}
}
if (clonedCollection == null) {