Compilation issue with requires static

Simone Bordet simone.bordet at
Fri Jan 21 10:46:04 UTC 2022


the issue is described in detail here:

To summarize, we have module A with: requires static X.
Then we have module B with: requires A.
Module B has test classes (that are patched into module B), and to
compile the test classes X is added to the class-path, and --add-reads
B=ALL-UNNAMED is also added.

My understanding is that a test class in module B should be able to
read classes from module X, due to the --add-reads directive.

However, the compiler (triggered by Maven, but you can see the full
command line in the issue linked above) reports:

[ERROR] /home/simon/tmp/compiler-bug/app/src/test/java/org/test/app/[12,38]
cannot access org.eclipse.jetty.util.ajax.JSON
[ERROR]   class file for org.eclipse.jetty.util.ajax.JSON not found

where MainTest is a test class in module B, and JSON is a class in module X.

The workaround is to put the jar of module X in the module-path, but
that seems unnecessary given the --add-reads directive.

Is the error expected behavior, or a javac bug?


Simone Bordet
Finally, no matter how good the architecture and design are,
to deliver bug-free software with optimal performance and reliability,
the implementation technique must be flawless.   Victoria Livschitz

More information about the compiler-dev mailing list