Inspectopedia 2025.3 Help

Declaration access can be weaker

Reports fields, methods or classes that may have their access modifier narrowed down.

Example:

class Sample { void foo() { bar("foo", "foo"); } void bar(String x, String y) { } // can be private }

After the quick-fix is applied:

class Sample { void foo() { bar("foo", "foo"); } private void bar(String x, String y) { } }

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

WeakerAccess
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | Java | Declaration redundancy

Use the inspection's options to define the rules for the modifier change suggestions.

Inspection ID: WeakerAccess

Inspection options

Here you can find the description of settings available for the Declaration access can be weaker inspection, and the reference of their default values.

Suggest package-private visibility level for class members

Option ID:

SUGGEST_PACKAGE_LOCAL_FOR_MEMBERS

Default value:

Selected
Suggest package-private visibility level for top-level classes

Option ID:

SUGGEST_PACKAGE_LOCAL_FOR_TOP_CLASSES

Default value:

Selected
Suggest 'private' for inner class members when referenced from outer class only

Option ID:

SUGGEST_PRIVATE_FOR_INNERS

Default value:

Not selected
Suggest weaker visibility for constants

Option ID:

SUGGEST_FOR_CONSTANTS

Default value:

Selected
Suggest package-private visibility level for classes in exported packages (Java 9+)

Option ID:

ep.moduleInfo

Default value:

Selected
Suggest package-private visibility level for junit 5 tests

Option ID:

ep.junit

Default value:

Selected

Suppressing Inspection

You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:

//noinspection WeakerAccess

More detailed instructions as well as other ways and options that you have can be found in the product documentation:

Inspection Details

By default bundled with:

IntelliJ IDEA 2025.3, Qodana for JVM 2025.3,

Last modified: 03 December 2025