Someone wrote a generic class that I wish to test. It looks something like:
public class foo <E>{  
     public static void main(String[] args){
         do_stuff();
     }
}
I have another class which tries to test the above function's static main method dynamically as follows:
public class Test{
   public static void main(String[] args){
         foo.class.getMethod("main").invoke(null,(Object[])new String[]{});
   }
}
When I try to run this, I get a java.lang.NoSuchMethodException. Why would this be the case? How can I fix it?
 
Aucun commentaire:
Enregistrer un commentaire