Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@SuppressWarnings value when having an Annotation as superinterface

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.

like image 810
user1294431 Avatar asked Nov 07 '12 00:11

user1294431


People also ask

What does @SuppressWarnings mean?

@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.

What is @SuppressWarnings unlikely ARG type?

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.

What is the use of @SuppressWarnings in Java?

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.

What is @SuppressWarnings unused?

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" ).


1 Answers

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.

like image 154
Bhesh Gurung Avatar answered Sep 21 '22 04:09

Bhesh Gurung