Developing an API, the warning message "Access can be package-package" in Java classes can be really annoying.
I've already spent some time going through the settings to find a way to disable this message but without any findings. Any idea how to disable the message?
The private modifier specifies that the member can only be accessed in its own class. The protected modifier specifies that the member can only be accessed within its own package (as with package-private) and, in addition, by a subclass of its class in another package.
"Package private" or "default" visibility modifier in Java is achieved by leaving out the visibility modifier (not the type). i.e. An improvement in the answer: Therefore, you do not need to explicitly declare any variable as package-private, no exception.
Go to Settings → Editor → Inspections
then Java → Declaration redundancy → Declaration access can be weaker
rule.
Here you can either disable it at all or select the suggestion options on the right pane:
To disable on a case by case basis, use
@SuppressWarnings("WeakerAccess")
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