Java 9 Nested (hierarchical or parent / child) modules

Is it possible to create based on inheritance (or nested) modules in Java 9?

Something like that:

module a
   |
   ├── module a1
   |   
   └── module a2

In this example, both the module a1and a2are the child elements a.

If I import one of the child modules, I would get the parent ( a) functionality along with any functionality defined in this child element. That is, I could import a1and explicitly access the functions of both a, and a1(but not a2).

Both a1and a2are aand can apply to all packages awithout opening the packages for them a.

+1
source share
1

, , requires transitive exports to:

  • requires transitive: , . , a1 a2 a.
  • exports to: ; a a1 a2, .

, :

module a {
    exports com.internal to a1;
    exports com.internal to a2;
}

module a1 {
    requires transitive a;
}

module a2 {
    requires transitive a;
}

, a1, a ( ) com.internal, a1 , .

, . a1 a a. , a1 a a; JLS (IE: exports * to a1, a1 a a, ), , .

+4

Source: https://habr.com/ru/post/1693537/


All Articles