Case - class from required module is not available
Alexey Fedorov
alexey.x.fedorov at oracle.com
Tue Mar 27 07:24:38 PDT 2012
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