-
Notifications
You must be signed in to change notification settings - Fork 60
Add Java module definitions #1028
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @A248 !
Much appreciated!
Skimming this from the phone seems reasonable, I'll have a closer look tomorrow.
Meanwhile I have a question is it possible to test the functionality somehow?
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? 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why exactly is checkstyle failing on module-info
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. I'd put a comment in here to that effect though.
pom.xml
Outdated
<compilerArgs> | ||
<arg>-XDcompilePolicy=simple</arg> | ||
<arg>--should-stop=ifError=FLOW</arg> | ||
<arg>-Xlint:-module</arg> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are module warnings disabled, specifically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is surprising
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
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 |
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 transitive
appropriately. 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.