I write a Groovy script and I need to access a field that has a private access modifier. This works fine but generates a warning:
Access to <field_name> exceeds its access rights
I want to supress this warning. What value of @SuppressWarnings annotation do I have to use in order to achieve it?
I've tried @SuppressWarnings("all") and it works fine but I would like to have more granular control over suppressions. I've also tried @SuppressWarnings("AccessingNonPublicFieldOfAnotherObject") but it has no effect.
Below how this warning looks in IntelliJ:

Unfortunately automatic hint doesn't suggest any sensible solution:

If you are talking about IntelliJ warning:

then you can hit Alt+Enter on the offender and choose "Suppress for method" as follows:

after which you will see @SuppressWarnings("GroovyAccessibility") over your test method:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With