Case - class from required module is not available
David Holmes
david.holmes at oracle.com
Tue Mar 27 18:48:47 PDT 2012
On 28/03/2012 3:53 AM, Mandy Chung wrote:
> This is an interesting scenario - module c is linked with module b only
> whereas module d is linked with module a only.
So is that a bug or a feature? Given b will not be able to find a<1.0,
but a1.0 is already loaded, is it then necessary that b not be linked to d?
David
-----
> $ jmod -L mlib dump-config c
> configuration roots = [c at 1.0]
> context +c
> module c at 1.0
> view c at 1.0
> local (1)
> c.C:c at 1.0
> remote (46)
> b=+b
> context +b
> module b at 1.0
> view b at 1.0
> local (1)
> b.B:b at 1.0
> remote (45)
> ....
>
> $ jmod -L mlib dump-config d
> configuration roots = [d at 1.0]
> context +d
> module d at 1.0
> view d at 1.0
> local (1)
> d.D:d at 1.0
> remote (45)
> context +a
> module a at 1.0
> view a at 1.0
> remote (45)
> ....
>
> module c requires module b and an optional dependence on module c.
> module b has an optional dependence on module a@<1.0 which does not
> exist. Thus module c is not linked with module a at 1.0 as it doesn't
> satisfy the dependence constraint.
>
> module d has an optional dependence on both module a and b with no
> version specified. The resolver attempts to resolve module d with module
> a at 1.0 and b at 1.0. Since there is no module satisfying the dependence from
> module d *and* from module b on a - i.e. "requires optional a" and
> "requires optional a@<1.0", module a at 1.0 is not resolved and linked in
> module d's configuration.
>
> Mandy
>
> On 3/27/2012 7:24 AM, Alexey Fedorov wrote:
>> Hello!
>>
>> Suppose we have simple construction with 4 modules:
>>
>> ****************************************
>>
>> module a @ 1.0 {
>> }
>>
>> ****************************************
>>
>> module b @ 1.0 {
>> requires optional a@<1.0;
>> exports b;
>> }
>>
>> package b;
>> public class B {
>> }
>>
>> ****************************************
>>
>> module c @ 1.0 {
>> requires optional a;
>> requires b;
>>
>> exports c;
>> class c.C;
>> }
>>
>> package c;
>> public class C {
>> public static void main(String[] args) {
>> try {
>> Class bClazz = Class.forName("b.B");
>> System.out.println(bClazz + " is AVAILABLE from c.C!");
>> } catch (ClassNotFoundException e) {
>> System.out.println("b.B is NOT AVAILABLE from c.C!");
>> }
>> }
>> }
>>
>> ****************************************
>>
>> module d @ 1.0 {
>> requires optional a;
>> requires optional b;
>>
>> exports d;
>> class d.D;
>> }
>>
>> package d;
>> public class D {
>> public static void main(String[] args) {
>> try {
>> Class bClazz = Class.forName("b.B");
>> System.out.println(bClazz + " is AVAILABLE from d.D!");
>> } catch (ClassNotFoundException e) {
>> System.out.println("b.B is NOT AVAILABLE from d.D!");
>> }
>> }
>> }
>>
>> ****************************************
>>
>> Running c.C and d.D in sequence shows:
>>
>>> class b.B is AVAILABLE from c.C!
>>> class b.B is NOT AVAILABLE from d.D!
>>
>> and it seems very strange for me. Could you please clarify, why class
>> b.B is not available from d.D?
>>
>> --
>> Alexey
>>
>>
More information about the jigsaw-dev
mailing list