How can I suppress the following error with the @SuppressWarning annotation?
The method
Foo.trololo()does not override the inherited method fromBarsince it is private to a different package
So far as I can tell the only way is to blanket the entire method with @SuppressWarning("all") which I would prefer not to do.
For clarification: The naming and scope of both methods is a deliberate choice and the two classes were deliberately put into different packages knowing the methods would not be visible to each other. I am merely looking to declare that I acknowledge what I am doing and would not like to be warned of it.
What it means (you probably know this already)
It means that, even though your method has the same name as a (non-private) method in the super class, it doesn’t override that method.
Regarding the warning message
This is an Eclipse-specific warning. Nothing in the language spec says that it should produce this warning. It’s an "IDE-specific feature" if you so like. Therefore there is no "generic" way of suppressing the message.
(Note for instance that
javacdoes not produce this warning.)How to disable this warning (in Eclipse)
(I know you are not looking for this, but some other visitor of this page may!)
To disable this warning, you go to
Window -> Preferences -> Java -> Compiler -> Errors / Warnings
and set "Method does not override package visible method" to "Ignore".