Program: 35825
Project: 35825
Buggy source:
/** 
 * Returns an array containing   {@code Method} objects reflecting all thepublic methods of the class or interface represented by this  {@code Class} object, including those declared by the class or interface andthose inherited from superclasses and superinterfaces. <p> If this  {@code Class} object represents a type that has multiplepublic methods with the same name and parameter types, but different return types, then the returned array has a  {@code Method} object foreach such method. <p> If this  {@code Class} object represents a type with a classinitialization method  {@code <clinit>}, then the returned array does <em>not</em> have a corresponding   {@code Method} object.<p> If this  {@code Class} object represents an array type, then thereturned array has a  {@code Method} object for each of the publicmethods inherited by the array type from  {@code Object}. It does not contain a   {@code Method} object for {@code clone()}. <p> If this   {@code Class} object represents an interface then thereturned array does not contain any implicitly declared methods from {@code Object}. Therefore, if no methods are explicitly declared in this interface or any of its superinterfaces then the returned array has length 0. (Note that a   {@code Class} object which represents a classalways has public methods, inherited from  {@code Object}.) <p> If this   {@code Class} object represents a primitive type or void,then the returned array has length 0. <p> Static methods declared in superinterfaces of the class or interface represented by this  {@code Class} object are not considered members ofthe class or interface. <p> The elements in the returned array are not sorted and are not in any particular order.
 * @return the array of {@code Method} objects representing thepublic methods of this class
 * @throws SecurityException If a security manager, <i>s</i>, is present and the caller's class loader is not the same as or an ancestor of the class loader for the current class and invocation of  {@link SecurityManager#checkPackageAccess s.checkPackageAccess()} denies access to the packageof this class.
 * @jls 8.2 Class Members
 * @jls 8.4 Method Declarations
 * @since 1.1
 */
@CallerSensitive public Method[] getMethods() throws SecurityException {
  checkMemberAccess(Member.PUBLIC,Reflection.getCallerClass(),true);
  return copyMethods(privateGetPublicMethods());
}

Fixed version (ground truth):
/** 
 * Returns an array containing   {@code Method} objects reflecting all thepublic methods of the class or interface represented by this  {@code Class} object, including those declared by the class or interface andthose inherited from superclasses and superinterfaces. <p> If this  {@code Class} object represents an array type, then thereturned array has a  {@code Method} object for each of the publicmethods inherited by the array type from  {@code Object}. It does not contain a   {@code Method} object for {@code clone()}. <p> If this   {@code Class} object represents an interface then thereturned array does not contain any implicitly declared methods from {@code Object}. Therefore, if no methods are explicitly declared in this interface or any of its superinterfaces then the returned array has length 0. (Note that a   {@code Class} object which represents a classalways has public methods, inherited from  {@code Object}.) <p> The returned array never contains methods with names "  {@code <init>}" or "  {@code <clinit>}". <p> The elements in the returned array are not sorted and are not in any particular order. <p> Generally, the result is computed as with the following 4 step algorithm. Let C be the class or interface represented by this   {@code Class} object:<ol> <li> A union of methods is composed of: <ol type="a"> <li> C's declared public instance and static methods as returned by {@link #getDeclaredMethods()} and filtered to include only publicmethods.</li> <li> If C is a class other than  {@code Object}, then include the result of invoking this algorithm recursively on the superclass of C.</li> <li> Include the results of invoking this algorithm recursively on all direct superinterfaces of C, but include only instance methods.</li> </ol></li> <li> Union from step 1 is partitioned into subsets of methods with same signature (name, parameter types) and return type.</li> <li> Within each such subset only the most specific methods are selected. Let method M be a method from a set of methods with same signature and return type. M is most specific if there is no such method N != M from the same set, such that N is more specific than M. N is more specific than M if: <ol type="a"> <li> N is declared by a class and M is declared by an interface; or</li> <li> N and M are both declared by classes or both by interfaces and N's declaring type is the same as or a subtype of M's declaring type (clearly, if M's and N's declaring types are the same type, then M and N are the same method).</li> </ol></li> <li> The result of this algorithm is the union of all selected methods from step 3.</li> </ol>
 * @apiNote There may be more than one method with a particular nameand parameter types in a class because while the Java language forbids a class to declare multiple methods with the same signature but different return types, the Java virtual machine does not.  This increased flexibility in the virtual machine can be used to implement various language features.  For example, covariant returns can be implemented with  {@linkplain java.lang.reflect.Method#isBridge bridge methods}; the bridge method and the overriding method would have the same signature but different return types.
 * @return the array of {@code Method} objects representing thepublic methods of this class
 * @throws SecurityException If a security manager, <i>s</i>, is present and the caller's class loader is not the same as or an ancestor of the class loader for the current class and invocation of  {@link SecurityManager#checkPackageAccess s.checkPackageAccess()} denies access to the packageof this class.
 * @jls 8.2 Class Members
 * @jls 8.4 Method Declarations
 * @since 1.1
 */
@CallerSensitive public Method[] getMethods() throws SecurityException {
  checkMemberAccess(Member.PUBLIC,Reflection.getCallerClass(),true);
  return copyMethods(privateGetPublicMethods());
}