score:67
In the code in your question, the @SuppressWarnings("unused")
annotation is unnecessary because the method is either overriding another method from a superclass or implementing an interface. Even if you don't actually use the whatever
parameter it's mandatory to declare it, otherwise the @Override
annotation will produce an error (you'd be changing the signature of the overridden method if you removed the parameter.)
In some older versions of Eclipse the code as shown would not cause a warning, but in more recent releases it does. I believe it's a valid warning, and I'd rather remove the @SuppressWarnings("unused")
in this case.
score:5
Alternatively, if you think it's more correct to delete the SuppressWarnings annotation:
Window -> Preferences -> Java -> Compiler -> Errors/Warnings -> Unnecessary code -> Value of parameter is not used
and select Ignore in overriding and implementing methods
score:5
In my code there's no inheritance defining the 3 methods with @SuppressWarnings("unused")
This code gives 'Unnecessary @SuppressWarnings("unused")' in Eclipse Juno (latest version), but if I remove the @SuppressWarnings("unused"), I get "Constructor/Method is never used" warnings in IntelliJ IDEA 11.1.3
The methods aren't directly used in the project, only by 3rd party products Jackson, JAXB & GSON, so IntelliJ is right, I would say ...
public class EmailUnsendable extends SkjemaError {
private NestedCommand command; // Can't be Command (interface) because of GSON!
@SuppressWarnings("unused") // Used by Jackson/JAXB/GSON
public EmailUnsendable() {
}
public EmailUnsendable(String referenceNumber, String stackTrace, NestedCommand command) {
super(referenceNumber, stackTrace);
this.command = command;
}
@SuppressWarnings("unused") // Used by Jackson/JAXB/GSON
public NestedCommand getCommand() {
return command;
}
@SuppressWarnings("unused") // Used by Jackson/JAXB/GSON
public void setCommand(NestedCommand command) {
this.command = command;
}
}
I believe this is an error in Eclipse.
score:25
Go to
Window → Preferences → Java → Compiler → Errors/Warnings → Annotations.
And select Ignore for Unused '@SuppressWarnings` token.
Source: stackoverflow.com
Related Query
- Unnecessary @SuppressWarnings("unused")
- Unnecessary 'else' statement
- How to (safely) remove unnecessary Maven dependencies in Eclipse?
- Something like unnecessary code detector for NetBeans
- How to remove all unnecessary semicolons (at end of blocks)?
- Customize an Eclipse formatter to remove unnecessary curly braces
- How to remove unnecessary space on bottom eclipse panel/toolbar?
- Android notifications avoid unnecessary notification update
- Eclipse Java Editor Formatter adds unnecessary spaces to GWT JSNI method body
- Why Eclipse copies unnecessary files into the bin folder?
- Java8 code stop compiling and make me to do an unnecessary explicit casting
- Getting unnecessary error and warning in eclipse when laravel project is added
- unnecessary shift of cursor to console log
- How to do a specific completion action without adding some unnecessary comment ?
- Removing unnecessary import from a whole project
- What files are unnecessary when exporting an Eclipse Workspace to a version control repository?
- Eclipse BIRT - Unnecessary inline style with external CSS when rendering HTML
- How to force Java compiler to error if @Override is unnecessary
- Unnecessary JARs in Eclipse project - potential problems?
- Eclipse project shows an unnecessary project folder that cannot be removed
- Gradle eclipse task adds unnecessary test sources to Web Deployment Assembly in Spring Source Tools
- The reason of unnecessary crashes of eclipse
- Remove unnecessary Java casting in Eclipse/STS does not work?
- RCP exportWizard remove unnecessary items
- Automatically delete unnecessary files in an Eclipse project
- Unnecessary resource leak warning in Eclipse for file writer
- Eclipse performing several thousand unnecessary file requests
- Unnecessary imports in Eclipse CDT
- eclipse throwing unnecessary errors
- m2eclipse exclude unnecessary folders
More Query from same tag
- Disable fetching of p2 repository indexes
- m2eclipse error
- JPA why queries returining 2 objects doesn't work and the one returning one object works fine
- Java Eclipse, how to make Windowbuilder show all Panels after execution?
- Eclipse - Could not find any META-INF/persistence.xml file in the classpath
- Eclipse with tomcat : java.lang.reflect.InvocationTargetException when I try running a web service client
- Eclipse CDT can not resolve method in template class
- Strange Characters instead of actual titles in Eclipse
- java.lang.NoClassDefFoundError: Maven projects
- Eclipse can't reach mysql connector driver in the project path
- How to remove the border of an Icon in a JButton using Eclipse?
- Eclipse optimized configuration for better performance
- MinGW GCC and G++ Errors in Eclipse
- Ldap Apache Directory Studio can not open Root DSE in osx big sur
- Get OpenCV2.1 to run in windows using eclipse
- Module java.xml.bind not found
- Java to Excel: How to get value from main class to excel class in column B?
- Eclipse, Tomcat, Maven, Spring MVC, Mongo (and insanity)
- Eclipse CDT - Keyboard shortcuts or plugins for creating new Classes and methods from compile errors
- Cannot find the JSTL core library descriptor error in Eclipse
- Subclipse and JavaHL installation headache
- Eclipse, Android NDK, android.mk - access denied
- Eclipse: work with external XML-file in a userfriendly way
- Change location of .project and .cproject files in Eclipse CDT
- Problem with executor service in Eclipse for android app
- How to prevent InvocationTargetException when jar is running?
- Getting java.lang.OutOfMemoryError: Java heap space
- TestNG-java.lang.AbstractMethodError:org.testng.remote.support.RemoteTestNG6_9_10$DelegatingTestRunnerFactory
- Transitioning from FlexBuilder 3 to FlashBuilder 4 ... there and back again
- Fill @version tag with mercurial in eclipse / Keyword substitution