Yes, you are right that calling super() is uncommon, but that does not justify it's correctness.
Let me establish some points here.
1)
Calling super() in an overriden method should cause no harmful effects whatsoever. On the other hand, not calling super() can possibly result in some defects. One example is in the case of methods responsible for freeing resources - a failure to call super.cleanUp() can lead to leaks. Maybe. Maybe not. Why take the chance?
2)
If calling super() in your overriden method alters the semantics of your code, this is an indicator that you've gotten your inheritance wrong. Dodgy design perhaps. Hence another reason why calling super() is beneficial. You hit 2 birds with the same stone.
3)
Ultimately, calling super() is an aspect of writing "defensive code". FindBugs is a software that not only helps find bugs, but prevents
them, enforces "defensive programming", highlights subtleties, prevent
dodgy coding and "gotchas" etc. Therefore I feel this should be implemented.
A penny for your thoughts, folks?
On Thu, Jun 5, 2008 at 1:46 AM, Andreas Probst <
andpro77@...> wrote:
It's perfectly fine not to call super from a sub-class. And the
longer I think about it, I believe it's rather uncommon to do so.
Exception: In constructors you usually call super().
On 5 Jun 2008 at 0:34, Imran Fanaswala wrote:
> Hello there,
>
> I wonder why such an obvious gotcha has not been considered and
> incorporated into Findbugs... Here's a simple example:
>
http://pastebin.com/mc404130
>
> Note, this is true even if the parent class is abstract
>
> Regards,
> Imran.
>
_______________________________________________
Findbugs-discuss mailing list
Findbugs-discuss@...
https://mailman.cs.umd.edu/mailman/listinfo/findbugs-discuss
_______________________________________________
Findbugs-discuss mailing list
Findbugs-discuss@...
https://mailman.cs.umd.edu/mailman/listinfo/findbugs-discuss