Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable "Access can be package-private" message in IntelliJ?

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?

like image 971
Thomas Avatar asked Jan 18 '17 09:01

Thomas


People also ask

Can private members be accessed in the same package?

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.

Can we make package private in Java?

"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.


2 Answers

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:

enter image description here

like image 113
DimaSan Avatar answered Oct 02 '22 18:10

DimaSan


To disable on a case by case basis, use

@SuppressWarnings("WeakerAccess") 
like image 20
seekingStillness Avatar answered Oct 02 '22 19:10

seekingStillness