Automatic modules and services
Paul Bakker
paul.bakker.nl at gmail.com
Fri Apr 8 12:16:32 UTC 2016
Excellent, thanks for the reply!
Paul
> On 08 Apr 2016, at 14:15, Alan Bateman <Alan.Bateman at oracle.com> wrote:
>
> On 08/04/2016 13:01, Paul Bakker wrote:
>> 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.
>>
> Thanks for the mail. This is (or rather was) a bug. It's fixed in the jake forest but hasn't been brought to JDK 9 yet. We hope to have the EA builds [1] publishing again soon, in which case there will be daily builds for those that don't build from sources.
>
> -Alan
>
> [1] https://jdk9.java.net/jigsaw/
More information about the jigsaw-dev
mailing list