RFR: 8358015: Fix SequencedMap sequenced view method specifications [v2]
Stuart Marks
smarks at openjdk.org
Wed Jun 4 22:33:54 UTC 2025
On Wed, 4 Jun 2025 16:50:15 GMT, Johannes Döbler <duke at openjdk.org> wrote:
>> 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.
The `@Override` annotation doesn't help with the main maintenance issue facing the collections framework, which occurs when an overriding method is missing. Virtually all of the public methods in the collection implementation classes are overrides. Adding an `@Override` annotation to every one of these would add a considerable amount of clutter for little benefit.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25515#discussion_r2127545058
More information about the core-libs-dev
mailing list