I am wondering about JDK9 modules. Say you have the following 3 packages:
com.company.product
com.company.product.impl_a
com.company.product.impl_b
Classes in package product.impl_a and product.impl_b can only be accessed by classes in package product. The user should only use classes from product package. You can imagine that passing certain flags or properties will decide whether impl_a or impl_b will be used, internally.
In JDK8-, you have to make these classes inside impl_a and impl_b public. This kinda sucks, because users can be tricked that they can use these classes. It's perfectly valid and allowed.
How can JDK9 help here? Will we declare a module for product.impl_a and another one for product.impl_b and declare that the exported classes are only to be accessed by a third module product, which will depend on the two modules product.impl_a and product.impl_b? In addition, it will be effectively impossible to declare a new module which will depend on product.impl_a or product.impl_b? Can other modules only depend on module product?