Here you can find the source of invokeAndCastCollection(T returnType, Method m, Object obj, Object... args)
@SuppressWarnings({ "unchecked" }) public static <T> Collection<T> invokeAndCastCollection(T returnType, Method m, Object obj, Object... args)
//package com.java2s; // SMSLib is distributed under the terms of the Apache License version 2.0 import java.lang.reflect.Method; import java.util.Collection; public class Main { /**//from w w w . ja va2 s. com * Same as * {@link ReflectionHelper#invokeAndCast(Object, Method, Object, Object...) but with a cast to Collection<T> } * * @see ReflectionHelper#invokeAndCast(Object, Method, Object, Object...) */ @SuppressWarnings({ "unchecked" }) public static <T> Collection<T> invokeAndCastCollection(T returnType, Method m, Object obj, Object... args) { try { return (Collection<T>) m.invoke(obj, args); } catch (Exception e) { throw new RuntimeException(e); } } }