// if we reach this point we have at least one parameter or return type, that
// is different in its specified form. That means we have to create a bridge method!
ClassNode testmr = correctToGenericsSpec(genericsSpec,omr);
if (!isAssignable(mr,testmr)){
throw new RuntimeParserException(
"The return type of "+
overridingMethod.getTypeDescriptor()+
" in "+overridingMethod.getDeclaringClass().getName()+
" is incompatible with "+
oldMethod.getTypeDescriptor()+
" in "+oldMethod.getDeclaringClass().getName(),
overridingMethod);
}
if ((oldMethod.getModifiers()&ACC_FINAL)!=0) {
throw new RuntimeParserException(
"Cannot override final method "+
oldMethod.getTypeDescriptor()+
" in "+oldMethod.getDeclaringClass().getName(),
overridingMethod);
}
if (oldMethod.isStatic() != overridingMethod.isStatic()){
throw new RuntimeParserException(
"Cannot override method "+
oldMethod.getTypeDescriptor()+
" in "+oldMethod.getDeclaringClass().getName()+
" with disparate static modifier",
overridingMethod);
}
if (!equalReturnType) {
boolean oldM = ClassHelper.isPrimitiveType(oldMethod.getReturnType());
boolean newM = ClassHelper.isPrimitiveType(overridingMethod.getReturnType());
if (oldM || newM) {
String message="";
if (oldM && newM) {
message = " with old and new method having different primitive return types";
} else if (newM) {
message = " with new method having a primitive return type and old method not";
} else if (oldM) {
message = " with old method having a primitive return type and new method not";
}
throw new RuntimeParserException(
"Cannot override method " +
oldMethod.getTypeDescriptor() +
" in " + oldMethod.getDeclaringClass().getName() +
message,
overridingMethod);