I have an enum which implements an Annotation and I'm getting the warning: The annotation type A should not be used as a superinterface for MyClass.
Is there a value for @SuppressWarnings which handles this warning? I don't want to use @SuppressWarnings("all"), I'd rather have the warning than suppress all of them.
I'm using Eclipse.
@SuppressWarnings instruct the compiler to ignore or suppress, specified compiler warning in annotated element and all program elements inside that element. For example, if a class is annotated to suppress a particular warning, then a warning generated in a method inside that class will also be separated.
This implies that the compiler may show "unwanted" warnings, or filter out invocations that are in fact bugs. For the former case, @SuppressWarnings("unlikely-arg-type") will document the exception both for the user and for the compiler.
Use of @SuppressWarnings is to suppress or ignore warnings coming from the compiler, i.e., the compiler will ignore warnings if any for that piece of code. 1. @SuppressWarnings("unchecked") public class Calculator { } - Here, it will ignore all unchecked warnings coming from that class.
The @SuppressWarnings annotation disables certain compiler warnings. In this case, the warning about deprecated code ( "deprecation" ) and unused local variables or unused private methods ( "unused" ).
I believe there is no such value for the @SuppressWarnings
. If there was such a value then the compiler would have given you a hint on using it along with the warning.
Since, it doesn't exist, it probably means that it isn't a good idea to make your enum extend an annotation.
And if you still want to go that way then I think @SuppressWarnings("all")
is the only option you have.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With