Here you can find the source of getMethod(Class> clss, String name, Class>... params)
Parameter | Description |
---|---|
NoSuchMethodException | an exception |
public static Method getMethod(Class<?> clss, String name, Class<?>... params)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Method; public class Main { /**/* w ww .j a va 2 s . c o m*/ * Gets the given method or throw exception. * @throws NoSuchMethodException */ public static Method getMethod(Class<?> clss, String name, Class<?>... params) { try { return clss.getMethod(name, params); } catch (NoSuchMethodException e) { fatal("Method " + name + " does not exist", e); return null; } } /** Print fatal error and exit. */ public static <T> T fatal(String message, Exception e) { System.out.println(message); if (e != null && System.getProperty("stacktrace") != null) e.printStackTrace(); System.exit(0); return (T) null; } }