class Class {
@CallerSensitive
public Method getMethod(String name, Class<?>... parameterTypes)
throws NoSuchMethodException, SecurityException {
Objects.requireNonNull(name);
SecurityManager sm = System.getSecurityManager();
if
(sm !=
null
) {
checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(),
true
);
}
Method method = getMethod0(name, parameterTypes);
if
(method ==
null
) {
throw
new
NoSuchMethodException(methodToString(name, parameterTypes));
}
return
getReflectionFactory().copyMethod(method);
}
@CallerSensitive
public Method getDeclaredMethod(String name, Class<?>... parameterTypes)
throws NoSuchMethodException, SecurityException {
Objects.requireNonNull(name);
SecurityManager sm = System.getSecurityManager();
if
(sm !=
null
) {
checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(),
true
);
}
Method method = searchMethods(privateGetDeclaredMethods(
false
), name, parameterTypes);
if
(method ==
null
) {
throw
new
NoSuchMethodException(methodToString(name, parameterTypes));
}
return
getReflectionFactory().copyMethod(method);
}
}