0

I wonder if it's possible to locally suppress errorprone warnings without getting an Eclipse warning instead. For example, with this line

private final byte[] magicBytes;

in an enum, I get the ImmutableEnumChecker warning as byte[] is mutable. This makes sense, but I ensured that it never leaks and never gets mutated, so I'd like to suppress the warning here. I don't want to suppress it globally, so I can't use the command line parameters and with

@SuppressWarnings("ImmutableEnumChecker")

I only trade the errorprone warning for the Eclipse warning Unsupported @SuppressWarnings("ImmutableEnumChecker").

Before, I used to use findbugs which has @SuppressFBWarnings for this very reason....

Is there something like "SuppressFBWarnings" in errorprone? Or any other solution?

maaartinus
  • 44,714
  • 32
  • 161
  • 320
  • What do you mean with errorprone? The google's [error prone](https://errorprone.info)? – Lonzak Jan 29 '20 at 14:46
  • @Lonzak Sure. Edited. – maaartinus Jan 30 '20 at 00:35
  • On the official [errorprone website](https://errorprone.info/docs/installation) you can read "For now, Eclipse users should use the Findbugs eclipse plugin instead, as it catches many of the same issues." So how do you show those warnings at all in eclipse? – Lonzak Jan 30 '20 at 14:13
  • @Lonzak I don't get the errorprone warning in Eclipse. But when I *suppress* the warning using e.g., `@SuppressWarnings("ImmutableEnumChecker")`, then Eclipse complains about not knowing the "ImmutableEnumChecker" token. – maaartinus Jan 30 '20 at 15:52

1 Answers1

1

There is an option in eclipse to supress the @SuppressWarnings("ImmutableEnumChecker") annotation. Go to Settings -> Java -> Compiler -> Errors/Warnings -> Annotations -> Unhandled Token in '@SuppressWarnings' and set it to ignore.

Additionally there are bug/feature reports for eclipse where you can vote/contribute:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=392045

https://bugs.eclipse.org/bugs/show_bug.cgi?id=122475

Lonzak
  • 9,334
  • 5
  • 57
  • 88
  • Thanks, the setting is a good workaround (not a solution as your links show). IMHO this should be fixed in errorprone, more precisely, every tool should provide their own annotation (like findbugs does), so that not every IDE must handle all tokens. – maaartinus Jan 30 '20 at 20:48