3

I have a project that I'm trying to play around with the Immutables Criteria: https://immutables.github.io/criteria.html

I added the following to my pom.xml:

 <dependency>
  <groupId>org.immutables</groupId>
  <artifactId>criteria-inmemory</artifactId>
  <version>2.8.2</version>
</dependency>

Everything seemed fine. However, I am having some issues getting things imported and working. I have no issues with Immutables.Value that works fine. When I import Criteria Eclipse complains about:

The type org.immutables.criteria.Criteria is not accessible

So I tried adding the module to my module-info.java as follows:

requires org.immutables.criteria-common;

Also tried:

requires org.immutables.criteria-inmemory;

I'm using Eclipse suggestions to auto-complete the module name because I don't really know what the module name should be but, when I add the above Eclipse says there is a syntax error with the "-" in the requires statement. So at this point I am kinda stuck! If anyone has any suggestions I would love to hear them!

Thanks!!

Marc Le Bihan
  • 2,308
  • 2
  • 23
  • 41
umhelp
  • 175
  • 8
  • 1
    Try using the command line `jar --describe-module --file .jar` to be sure of what to use. – Naman Sep 30 '20 at 14:03
  • Uh oh... $ jar --describe-module --file ./criteria-common-2.8.2.jar Unable to derive module descriptor for: ./criteria-common-2.8.2.jar Automatic-Module-Name: org.immutables.criteria-common: Invalid module name: 'criteria-common' is not a Java identifier. Any thoughts on this one?!? – umhelp Sep 30 '20 at 16:27
  • 1
    Yes. You would land up to - https://stackoverflow.com/questions/46501388/unable-to-derive-module-descriptor-for-auto-generated-module-names-in-java-9 – Naman Sep 30 '20 at 17:01
  • That is right on the money. Except it seems that solution is for the library maintainer though? How would a user of the given jar-file update that? Using that solution sounds like I would have to wait until the library has added module descriptors or have an Automatic-Module-Name. I'm new to this level of module hacking so I may be missing something. Thanks!! – umhelp Sep 30 '20 at 18:20
  • 1
    The other solution that you would be left with would be to hack into the jar file with something like `jar --update --file --manifest=`, but that wouldn't be a reliable way forward – Naman Oct 01 '20 at 10:52

1 Answers1

1

I was able to track down the issue with the Immutables Library and I posted the following issue: https://github.com/immutables/immutables/issues/1223

Basically, the library was creating an invalid Automatic-Module-Name tag in there pom.xml's when building the jar files. The values that we being set contained a "-" which is invalid.

Shoutout to @Naman for pointing me in the right direction! Thanks!

I am still wondering if it is possible to override the jar files module-name. It seems like it could be useful for users of a library to somehow override a libraries jar files module-name for situations like this.

umhelp
  • 175
  • 8