Reputation:
I have a function that is called only in debug mode. If I do not add:
@SuppressWarnings("unused")
I get a warning because the function is never used, in non debug mode.
If I add it a get a warning because for an Unnecessary @SuppressWarnings("unused")
, in debug mode.
What do you normally do to avoid it?
Upvotes: 0
Views: 543
Reputation: 533492
You can make the flag which checks for debug mode not statically determined.
static final boolean DEBUG = Boolean.getBoolean("debug");
or
static final boolean DEBUG = LOGGER.isDebugEnabled();
or
static final boolean DEBUG = Boolean.parseBoolean("true");
This will stop the static analysis being about to determine whether you have debug enabled or not.
Upvotes: 2
Reputation: 31
You can try and make the method protected and that should remove the warning. The other option is to change the preferences.
Upvotes: 0