I have a method signature that looks like
public void (Foo<T> foo)
In this method I need to call a method that takes
Class<T> clazz
as an argument. How can I get a reference of type Class<T> from foo? Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Due to type erasure, you cannot get directly at type parameters. The information is simply not present at runtime. API that needs reference to type parameter’s class needs to take class object instance…
public void abc(Foo<T> foo, Class<T> clazz)