简体   繁体   中英

How to suppress errorprone warnings without getting a warning from eclipse?

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM