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.

s'marks

Reply via email to