Java Magazine, Sept/Oct 2017
ORACLE COM JAVAMAGAZINE SEPTEMBER OCTOBER 2017 22 java 9 Consider the following directive from the java desktop module declaration requires transitive java xml In this case any module that reads java desktop also implicitly reads java xml For example if a method from the java desktop module returns a type from the java xml module code in modules that read java desktop becomes dependent on java xml Without the requires transitive directive in java desktops module declaration such dependent modules will not compile unless they explicitly read java xml According to JSR 379 Java SEs standard modules must grant implied readability in all cases like the one described here Also though a Java SE standard module may depend on non standard modules it must not grant implied readability to them This ensures that code depending only on Java SE standard modules is portable across Java SE implementations exports and exports to An exports module directive specifies one of the modules packages whose public types and their nested public and protected types should be accessible to code in all other modules An exports to directive enables you to specify in a comma separated list precisely which modules or modules code can access the exported package this is known as a qualified export uses A uses module directive specifies a service used by this module making the module a service consumer A service is an object of a class that implements the interface or extends the abstract class specified in the uses directive provides with A provides with module directive specifies that a module provides a service implementation making the module a service provider The provides part of the directive specifies an interface or abstract class listed in a modules uses directive and the with part of the directive specifies the name of the service provider class that implements the interface or extends the abstract class open opens and opens to Before Java 9 reflection could be used to learn about all types in a package and all members of a type even its private members whether you wanted to allow this capability or not Thus nothing was truly encapsulated
You must have JavaScript enabled to view digital editions.