javac -Xlint:overrides not working

狂风中的少年 提交于 2019-12-05 13:00:40

I believe you are misunderstanding the Xlint:overrides behaviour.

To my knowledge, enabling this check will cause the compiler to emit warnings (or maybe errors) when it encounters a method annotated with @Override that does not actually override a superclass method. It does not, however, check that all overridden methods are annotated correctly.

EDIT: Just tested it. The compiler will emit an error when you specify @Override on a method that does not override a superclass method, with or without the Xlint option.

The documentation on Oracle's website doesn't even mention the Xlint:overrides option so I'm guessing it's not implemented.

Xlint:overrides is more subtle than @Override. @Override (as Cameron Skinner points out) will cause an error to be emitted by the compiler if it annotates a method which does not in fact override another method. The Xlint:overrides option, however, produces a warning if one has marked a method with a varargs parameter to override another which doesn't have a varargs parameter but instead uses an array. A good explanation is found here:

http://marxsoftware.blogspot.com/2010/10/javacs-xlint-options.html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!