automatic modules leaking types when using addmods
Paul Bakker
paul.bakker.nl at gmail.com
Sun Apr 24 09:57:31 UTC 2016
Hello,
Another question related to automatic modules.
I have the following code:
import com.fasterxml.jackson.core.JsonFactory;
...
JsonFactory f = new JsonFactory();
System.out.println(f.getCodec());
This code clearly depends on jackson.core. So my module-info contains:
requires jackson.core;
This is as expected. I can change the module-info to the following however (removing the dependency on jackson.core):
requires jackson.databind;
At first sight, this fails to compile as expected, because the JsonFactory type comes from jackson.core, not from jackson.databind.
But when I add "-addmods jackson.core" to my build command, it builds successfully! That's not what I would expect, because my module doesn't declare a dependency on jackson.core. Why does this happen? I would expect that the -addmods adds the module to the available modules, but does not magically add read edges to named modules.
When removing the "jackson.databind" requires in my module-info, it fails to compile again, so it looks like jackson.databind somehow leaks types from jackson.core to my module.
The build command I use is the following:
javac -mp mods -addmods jackson.core -d out -modulesourcepath src $(find src -name '*.java')
Best regards,
Paul Bakker
More information about the jigsaw-dev
mailing list