Hi,
I found an interesting issue with automatic modules that contain services. I
have a small application that depends on jackson-core, jackson-databind and
jackson-annotations.
As an experiment I started the app with only the jackson-databind jar file on
the modulepath, which turns it into an automatic module. The application code,
and the other two Jackson libs are still on the classpath.
java -cp
out:lib/jackson-annotations-2.7.3.jar:lib/jackson-core-2.7.3.jar -mp mods
-addmods jackson.databind com.javamodularity.demonstrator.Demo
This gives the following exception:
java.lang.module.ResolutionException: Module jackson.databind does not
read a module that exports com.fasterxml.jackson.core
This is surprising, because jackson-databind is an automatic module, which
should read the unnamed module. The unnamed module should contain jackson-core
because it's on the classpath.
The real surprise is that this seems to be caused by jackson-databind having a
service declaration in it's META-INF of type
"com.fasterxml.jackson.core.ObjectCodec". It looks like an automatic module
can't declare a service of a type declared in the unnamed module.
When I remove the service declaration from the jackson-databind JAR, it runs
without exceptions.
Is this a bug or desired behaviour? When placing jackson-core on the modulepath
as well everything works as expected, but that's besides the point I think.
Best regards,
Paul Bakker