Inspectopedia
 
2024.3

Redundant 'requires' directive in module-info

Warning
New
Last modified: 03 December 2024

Reports redundant requires directives in Java Platform Module System module-info.java files. A requires directive is redundant when a module A requires a module B, but the code in module A doesn't import any packages or classes from B. Furthermore, all modules have an implicitly declared dependence on the java.base module, therefore a requires java.base; directive is always redundant.

The quick-fix deletes the redundant requires directive. If the deleted dependency re-exported modules that are actually used, the fix adds a requires directives for these modules.

This inspection only reports if the language level of the project or module is 9 or higher.

New in 2017.1