What happened to Java @OverridingMethodMustCallSuper?

Did I dream it? I could have sworn I read something about java 7, providing annotations that you could put on a method so that all subclasses call super. Was it renamed or dropped, or was it never considered?

+4
source share
2 answers

It was part of JSR 305: Annotations for detecting software defects and was called @OverridingMethodsMustInvokeSuper .

JSR is inactive, but the reference implementation is bundled with FindBugs

+4
source

Perhaps this was suggested for the Coin project, which accepted many proposals, but chose the best / easiest from the list.

You can do it instead.

 public final void method() { // super code subClassMethod(); } protected void subClassMethod() { // can be overridden. } 
+3
source

Source: https://habr.com/ru/post/1385555/


All Articles