Lets say...
<T, S extends T> void work(final Class<T> type, final S object) {}
or
<T> void work(final Class<T> type, final T object) {}
How can I pass following parameters to work()?
final Class<?> type = <not null> // This is actually an reflection output.
final Object object = <not null>
assert type.isInstance(object); // this is absolutely guaranteed
work(type, type.cast(object)); // compile error; how can I do this?
work(type, object); // compile error; how can I do this?
void work(Class<?> type, Object object)and I put a conditional check fortype.isInstance(object). Did I do right? Thank you.