JAVADOC clarification needed in Class.getMethod

Kyung Koo Yoon yoonforh at gmail.com
Sat Aug 29 08:56:59 UTC 2015


Hi, all.

The javadoc comment of java.lang.Class.getMethod API has following clause.

@CallerSensitive
    public Method getMethod(String name, Class<?>... parameterTypes)
        throws NoSuchMethodException, SecurityException


"The {@code parameterTypes} parameter is an array of {@code Class} 
objects that identify the method's formal parameter types, in declared
 order. If {@code parameterTypes} is {@code null}, it is
 treated as if it were an empty array."

As you know the method signature changed to use varargs since JDK 1.5,
if parameterTypes is given null, the compiler will interpret the parameter with “new Class[] { null }”.

So, the javadoc comment can’t be happen and inaccurate in the view of the code.

I think it can be safely changed as below. or even better just remove the clause ;

If {@code parameterTypes} is missing, it is treated as if it were an empty array.

Regards,
  Yoon Kyung Koo

-- 
--------------------
 Software Innovation Driver yoonforh at gmail dot com
 Analyze, Reason, Reshape the Question
 PGP  http://www.javadom.com/personal/yoonforhatgmaildotcom.asc <http://www.javadom.com/personal/yoonforhatgmaildotcom.asc>



More information about the core-libs-dev mailing list