if (!method.getName().equals(otherMethod.getName())) {
return false;
}
Class[] params1 = method.getParameterTypes();
Class[] params2 = otherMethod.getParameterTypes();
int p = params1.length;
if (p != params2.length) {
return false;
}
while (--p >= 0) {
if (params1[p] != params2[p]) {
return false;
}
}
Class<?> thisMethodReturnType = method.getReturnType();
Class<?> otherMethodReturnType = otherMethod.getReturnType();
if (!thisMethodReturnType.isAssignableFrom(otherMethodReturnType)) {
if (otherMethodReturnType.isAssignableFrom(thisMethodReturnType)) {
// substitute returnType of method with that of otherMethod
method = otherMethod;
} else {
throw new IllegalArgumentException(Msg.getString("K00f2",
method.getName()));
}
}
if (commonExceptions.length != 0) {
Class[] otherExceptions = otherMethod.getExceptionTypes();
if (otherExceptions.length == 0) {
commonExceptions = otherExceptions;
} else {
int cLength = commonExceptions.length;
nextException: for (int c = 0, cL = cLength, oL = otherExceptions.length; c < cL; c++) {
Class<?> cException = commonExceptions[c];
for (int o = 0; o < oL; o++) {
Class<?> oException = otherExceptions[o];
if (cException == oException) {
continue nextException;
}
if (oException.isAssignableFrom(cException)) {
continue nextException; // cException is a subclass
}
if (cException.isAssignableFrom(oException)) {
// oException is a subclass, keep it instead
commonExceptions[c] = cException = oException;
continue nextException;
}
}
commonExceptions[c] = null;
cLength--;
}
if (cLength != commonExceptions.length) {
Class[] newExceptions = new Class[cLength];
for (int i = 0, j = 0, length = commonExceptions.length; i < length; i++) {
Class<?> ex = commonExceptions[i];
if (ex != null) {
newExceptions[j++] = ex;
}
}
commonExceptions = newExceptions;
}
}
}
return true;