How to suppress the "requires transitive directive for an automatic module" warning properly?

You could try out the option of switching off the warning using

-Xlint:-requires-transitive-automatic

The changes for which were merged with JDK-8178011 stating:-

There should be two new warnings:

  • when a named module "requires transitive" an automatic module (default on)
  • when a named module "requires" an automatic module (default off)

Inferring this from the changes made here and also from the edit to the JEP 261: Module System which confirms that(emphasis mine):-

In both of the modular modes the compiler will, by default, generate various warnings related to the module system; these may be disabled via the option -Xlint:-module.

More precise control of these warnings is available via the exports, opens, requires-automatic, and requires-transitive-automatic keys for the -Xlint option.


Sadly, the accepted answer didn't help me.
BTW, I am using Java 14 with a bunch of module system hacks for JUnit.

I had to add another flag, so the complete list looks as following:

-Xlint:-exports -Xlint:-requires-transitive-automatic -Xlint:-requires-automatic

I have searched for the error message and found the source code. There, one can see that the corresponding compiler key is called compiler.warn.leaks.not.accessible.not.required.transitive, with the command line arg -Xlint:exports.