I want my method "themethod" is referencing "foo", then in a static block, try to get the method "foo" with "getMethod", to which I pass the name of the method and type of the parameters, but "foo "receives as a parameter a type generic, then I know not to give to work. Code:
public class Clazz<T>
{
static Method theMethod;
static
{
try
{
Class<Clazz> c = Clazz.class;
theMethod = c.getMethod( "foo", T.class ); // "T.class" Don't work!
}
catch ( Exception e )
{
}
}
public static <T> void foo ( T element )
{
// do something
}
}
How do I make "theMethod" referencing a method called 'foo'?