On Thu, Dec 7, 2017 at 4:47 PM, Stuart Marks <stuart.ma...@oracle.com> wrote:
> > > On 12/7/17 3:50 PM, Jonathan Bluett-Duncan wrote: > > Looking over http://cr.openjdk.java.net/~smarks/reviews/8060192/webrev.2/ >> src/java.base/share/classes/java/util/ArrayList.java.cdiff.html, I'm >> wondering if the method `ArrayList.toArray(IntFunction)` should have an >> `@Override` to make it clear that it's overriding the default method in >> Collection. What do you think? >> > > I guess it wouldn't hurt. I had thought about adding it, but most of the > methods in ArrayList that override implementations from supertypes *don't* > have @Override. Looking more closely, it appears that the ones that > override interface default methods *do* have @Override. > > I don't think there's a rule that says that @Override should be used when > overriding interface default methods but not when overriding > implementations from a superclass or when implementing an abstract > interface method. Frankly, I think the JDK is just sloppy here. Most of the > existing implementations didn't use @Override -- possibly because they were > introduced before annotations existed -- and later on, whoever implemented > the overrides of the Java 8 default methods decided to add @Override. > Part of it is that Doug and I are not huge fans of @Override. Is the gain in safety really worth the added verbosity? If we do decide to mandate the use of @Override in all of openjdk, then the errorprone project has a bug pattern check for you, which will provide more safety yet.