JetBrains / java-annotations

Annotations for JVM-based languages.
Apache License 2.0
404 stars 47 forks source link

Add @OverridingMethodsMustInvokeSuper #22

Closed JojOatXGME closed 4 years ago

JojOatXGME commented 4 years ago

The Java | Inheritance issues | Method does not call super method inspection produces a warning when a method overrides another method without calling the super method. By default, this is only done when the super method is annotated with javax.annotation.OverridingMethodsMustInvokeSuper. I think that is a nice feature. Unfortunately, this annotation is not part of the official API and cannot be accessed when the JPMS (aka. Jigsaw) is used. I would like to see a similar annotation within this annotation module.

amaembo commented 4 years ago

For now, you can add custom annotation to your project and setup the inspection to recognize it.

amaembo commented 4 years ago

We created 'MustBeInvokedByOverriders' annotation. Will appear in the next release.

JojOatXGME commented 4 years ago

@amaembo Thanks!! I'm actually a little bit confused that you used RetentionPolicy.RUNTIME (like on the original annotation) instead of RetentionPolicy.CLASS as writtin in the CONTRIBUTING.md.

amaembo commented 4 years ago

Oops! Good catch, thanks! Fixed.