Add Java module definitions - #1028
Conversation
|
Theoretically, yes. Some behavior is different on the module path: Java's in practice, compilation will mostly ensure that the modules are declared properly. But if you want to spin up an integration test, you can always create a subproject that runs Chicory on the module path. This subproject can be created either as a plain Maven module, or using the maven-invoker-plugin. Theoretically speaking though, there's no way to reach 100% coverage unless you literally fork all test runs and run them in a modular environment. That's why I rely on |
|
Thanks for the answer, I don't think we need 100% coverage, but an integration test to check that we are not badly messing up will be good... |
|
@dmlloyd IIRC you played a bit with the module system, do you want to comment on this PR? 🙏 |
dmlloyd
left a comment
There was a problem hiding this comment.
The descriptors themselves look fine, but I would ensure there is testing from the start.
| <module name="BeforeExecutionExclusionFileFilter"> | ||
| <property name="fileNamePattern" value="module\-info\.java$"/> | ||
| </module> |
There was a problem hiding this comment.
Why exactly is checkstyle failing on module-info?
There was a problem hiding this comment.
module-info is wholly unsupported by checkstyle, so this is the recommended configuration (per their docs) to skip it.
There was a problem hiding this comment.
Makes sense. I'd put a comment in here to that effect though.
| <compilerArgs> | ||
| <arg>-XDcompilePolicy=simple</arg> | ||
| <arg>--should-stop=ifError=FLOW</arg> | ||
| <arg>-Xlint:-module</arg> |
There was a problem hiding this comment.
Why are module warnings disabled, specifically?
There was a problem hiding this comment.
In order to make "internal" packages stay internal to Chicory, I added qualified exports like exports ....internal to othermodule;.
However, this causes a warning message like "module not found". This happens because the downstream module is not present during module compilation. To work around this, we'd need to either disable the lint -- or to restructure Chicory in ways that are very unstandard for a Maven build (1)
Because of <failOnWarnings>, the module-related warning message was failing the build, so I disabled itt.
There was a problem hiding this comment.
I'd add a comment here too.
eb1dbd3 to
f27d73f
Compare
|
Good news! Not only did the tests caught a couple bugs, but they showed that the "internal" packages need to be exported after al. This obviates the need for All that considered, I don't have any other changes in mind to make to this PR, besides addressing your review concerns, of course. |
09f2d4f to
7d5a86f
Compare
| <configuration> | ||
| <compilerArgs> | ||
| <arg>--add-modules</arg> | ||
| <arg>java.sql</arg> |
There was a problem hiding this comment.
needed by approval tests apparently, we should make sure this configuration only apply during tests
7d5a86f to
191f735
Compare
|
I added a commit to disable checkstyle on Java 11, but now there is an issue with the modules. Just to make sure I ask it: are those changes fully backward compatible? |
|
Just to spell it out, I was waiting an iteration from you @A248 on this PR, let me know if you are going to have time to progress on it 🙂 and thanks again 🙏 |
|
Hi there, sorry for the delay. I took a look at the tests which were strangely failing on Java 11. What's weird is that the approvaltests dependency jar contains Anyway, I'll hopefully get to the bottom of this and update this PR with the fix. |
|
Potentially related: https://bugs.openjdk.org/browse/JDK-8338675 (javac modifies jar files when .java files are present inside them!) |
|
@dmlloyd if you have a spare cycle and are interested in having a look it would be appreciated 🙏 |
|
The build is failing for me locally, but per that JDK bug I'd try adding |
It turns out that chicory was already using the latest checkstyle version, so this commit just ensures that checkstyle is really turned off on Java 11
3a6a436 to
37c316e
Compare
|
@A248 I want those fixes for the next release that is likely to happen soon, hence I took over this PR, I hope you don't mind. |
|
All good! Thank you for taking over the PR. |
Aims to solve #1012
I added Java module definitions where I thought appropriate. Several of the subprojects aren't designed for external consumption, such as test suites and benchmarks.
Packages named "internal" I treated as internal to chicory, i.e. not intended for external consumption.
Additionally, I did my best to check when types from a dependency were exposed in a module's public API, in order to use
requires transitiveappropriately. It's possible I missed a spot, but this will never be breaking and will result in at most a compiler warning (on chicory's side) or the need to write anotherrequires(on the library user's side).Checkstyle
Chicory was still using checkstyle 9.3, which is still the default version in the maven-checkstyle-plugin. Because this old checkstyle version was running into problems consuming
module-info.java, I increased the version to the latest.This required checking for breaking changes in checkstyle, which I did by looking at every release since 9.3. Checkstyle does not follow SemVer so you have to look at every release notes.
Terminology
For people reading this PR, the PR itself targets the Java Modules introduced in Java 9. They are a separate concept from WASM modules.