cs-au-dk/dk.brics.automaton

Add support for JPMS modules

Opened this issue · 0 comments

mtf90 commented

Is there any interest in supporting JPMS modules introduced in Java 9? Currently, I am in the process of modularizing some projects and get a warning when using BRICS since the compiler is only able to infer a filename-based module name. I see two possibilities to address this issue.

  1. The least invasive approach would be to include an Automatic-Module-Name entry in the MANIFEST.MF file of the built JAR file. This would allow you to claim a module name (something like dk.brics.automaton) and get rid of the warnings without having to change too much of the build process. For example (in case of Maven), it would only require an additional config property on the jar-plugin.

  2. However, since BRICS barely has any dependencies, it would also be easy to add a full module-info.java descriptor which would allow people to conveniently use BRICS in more advanced setups that include jlink or jpackage. The drawback of this approach is that you would have to build BRICS on a JDK greater than 8. To not break compatibility with the current version, I would suggest to realize this with two compilation phases. One that compiles everything for Java 9+ (including the module-info) and one that re-compiles everything (except the module-info) for Java 8. Since module-info isn't a valid Java identifier, you can't reference this file in regular Java 8 applications. So unless you are doing some reflective JAR scanning, people shouldn't run into any problems with UnsupportedClassVersionErrors.

If interested, I could provide a PR for the initial support of this feature. However, since I am not really well-versed in Ant, I would probably need some help to adjust the build.xml as well.