[Clirr-devel] adding methods to interfaces
Status: Alpha
Brought to you by:
lkuehne
From: Simon K. <si...@ec...> - 2004-06-23 06:34:57
|
Hi, In MethodSetCheck, the reportMethodAdded method uses: final Severity severity = !newClass.isInterface() && (newClass.isFinal() || !newMethod.isAbstract()) ? Severity.INFO : Severity.ERROR; This means that adding a method to an interface is reported as an ERROR. However the java spec section 13.5.3 says: <quote> Adding a method to an interface does not break compatibility with pre-existing binaries </quote> I've tested this, and this seems to be correct: there will not be a *linktime* error reported under any circumstances. However if I have code which implements the old interface, and I then pass this object to code that tries to invoke a new method, an AbstractMethodError runtime exception occurs. So I think that this should be a WARNING, not an error. What do you think? ------------------------------- I'm also somewhat puzzled by the remainder of the ternary expression too. Adding an abstract method to a class is indeed a problem, because subclasses can exist which don't have that method. But like the interface issue, I think this is a WARNING (runtime problem) rather than an ERROR (linktime problem). And why is it ok to add an abstract method to a final class? Final classes are never allowed to be abstract, so this shouldn't be possible as far as I know.. Regards, Simon |