i have a method in a class like this:
public static void postEvents(List<RuleEvent> eventList) {
for(RuleEvent event:eventList)
if(canProcess(event))
findListenerAndPost(event);
}
and i want to access it using reflection like this:
Class partypes[] = new Class[1];
partypes[0] = List.class; //does not find the method as it is of List<RuleEvent>
postMethod = cls.getMethod("postEvents", partypes);
so, how do I get the class object of List<RuleEvent>????
I already know the way of ((List<RuleEvent>) new ArrayList<RuleEvent>()).getClass() but there should be a more direct way…
All you need is the following
The generic type is not required at runtime.