O'Reilly logo

Modular Programming in Java 9 by Koushik Kothagal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Configuring module dependency

Think of a module being a walled garden by default. By default, any Java type in a module is accessible only to the types inside the same module. Previously, the SortUtil class was in the packt.addressbook module and was thus accessible to other types in that module. Move it to a different module however, and it is not accessible to types in the original module anymore.

Given two modules, A and B, for any type in module A to access a type in module B, two conditions need to be satisfied:

  • Module A needs to declare its dependency on module B
  • Module B needs to declare that it's okay with that type being accessed externally by other modules

If either of these conditions isn't met, the type being accessed in module ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required