On Wed, 4 Jun 2025 16:19:23 GMT, Stuart Marks <sma...@openjdk.org> wrote:

>> It would be helpful in situations like this to have the inverse annotation 
>> -- "All methods should be overridden, except the ones marked `@NoOverride`".
>
> Interesting. This `@NoOverride` idea could be useful on a subclass that wants 
> to make sure it overrides everything. (Maybe `@NoInherit` would be a better 
> name.) Meanwhile for JDK-8357272 (PR 
> https://github.com/openjdk/jdk/pull/25478) we're implementing similar policy 
> checking in a test, though the exact policy is "no inheritance of default 
> methods."

> The `@Override` annotation has been inconsistently applied in the collections 
> implementations. In practice since so many methods are overridden, and some 
> test would likely fail if a method weren't overridden properly, the 
> annotation would mostly add clutter. Indeed I'm considering pulling out all 
> uses of `@Override` in certain areas because they're just clutter.

The @Override annotation was one of Java's best innovations to detect 
consequences of changes in a base class for derived classes at compile time and 
it also carries information to any developer looking at a method, so calling it 
clutter (in Collection implementations) seems like a bit of exaggeration to me. 
Some IDEs have a feature to automatically add @Override annotations on save, 
and I think the JDK would improve if missing @Override annotations would be 
added to the whole code base.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25515#discussion_r2127039998

Reply via email to