I have a long history.
java generics bounds type
generics ad to reflect
Anyway, I have a method that calls a method using reflection and returns a common result.
public static <V> JAXBElement<V> unmarshal(..., Class<V> valueType);
The problem (?) Occurs when I get the result of a method call. I have to drop it.
final Object result = method.invoke(...);
I found that I can use result in JAXBElement<V> as follows.
@SuppressWarnings("unchecked") final JAXBElement<V> result = (JAXBElement<V>) method.invoke(...); return result;
Is there any other way to do this? I mean, I used Class<V> valueType .
If not, is the following statement a bit cumbersome ?
Thanks.
source share