Hello,
I'm experimenting with automatic modules again. I have a module "demonstrator"
that uses Jackson Databind.
import com.fasterxml.jackson.databind.ObjectMapper;
....
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(modularityBook);
In module-info.java I have the following:
requires jackson.databind;
On the modulepath I have jackson.core, jackson.databind and jackson.annotations.
Building results in an error:
class file for com.fasterxml.jackson.core.Versioned not found
This makes sense because the ObjectMapper class that I'm using implements the
Versioned interface (from jackson.core).
When generating a module-info.java using jdeps for the jackson.databind JAR
however, it generates the following:
requires public jackson.annotations;
requires public jackson.core;
This is much closer to what I would expect when using the jackson.databind
module.
When using jackson.databind as an automatic module, I will end up with a list
of requires for transitive dependencies that I shouldn't have to care about.
Why don't automatic modules take better care of transitive dependencies, so
that the application's module-info looks similar to what it would after
transforming the dependencies to named modules?
Also, jdeps doesn't actually show this problem when looking at the code when
still on the classpath:
jdeps -cp lib/jackson-databind-2.7.3.jar
out/com/javamodularity/demonstrator/Demo.class
Demo.class -> lib/jackson-databind-2.7.3.jar
Demo.class -> java.base
com.javamodularity.demonstrator (Demo.class)
-> com.fasterxml.jackson.databind
jackson-databind-2.7.3.jar
-> java.io
-> java.lang
Best regards,
Paul Bakker