最近遇到一个问题,java非静态的内部类,在调用到java.lang.Class.getConstructor(Class<?>...)这个方法时,抛出了异常NoSuchMethodException,这是为什么呢?
仔细看java.lang.Class.getConstructor(Class<?>...)这个方法的注释,如下:
/**
* Returns a <code>Constructor</code> object that reflects the specified
* public constructor of the class represented by this <code>Class</code>
* object. The <code>parameterTypes</code> parameter is an array of
* <code>Class</code> objects that identify the constructor's formal
* parameter types, in declared order.
*
* If this <code>Class</code> object represents an inner class
* declared in a non-static context, the formal parameter types
* include the explicit enclosing instance as the first par