Java Magazine, September/October 2017
ORACLE COM JAVAMAGAZINE SEPTEMBER OCTOBER 2017 19 java 9 there have been various efforts geared to modularizing Java but none is widely used and none could be used to modularize the Java platform Modularizing the Java SE platform has been challenging to implement and the efort has taken many years JSR 277 Java Module System was originally proposed in 2005 for Java 7 This JSR was later superseded by JSR 376 Java Platform Module System and targeted for Java 8 The Java SE platform is now modularized in Java 9 but only after Java 9 was delayed until September 2017 Each module must explicitly state its dependencies Goals According to JSR 376 the key goals of modularizing the Java SE platform are Reliable configuration Modularity provides mechanisms for explicitly declaring dependencies between modules in a manner thats recognized both at compile time and execution time The system can walk through these dependencies to determine the subset of all modules required to support your app Strong encapsulation The packages in a module are accessible to other modules only if the module explicitly exports them Even then another module cannot use those packages unless it explicitly states that it requires the other modules capabilities This improves platform security because fewer classes are accessible to potential attackers You may find that considering modularity helps you come up with cleaner more logical designs Scalable Java platform Previously the Java platform was a monolith consisting of a massive number of packages making it challenging to develop maintain and evolve It couldnt be easily subsetted The platform is now modularized into 95 modules this number might change as Java evolves You can create custom runtimes consisting of only modules you need for your apps or the devices youre targeting For example if a device does not support GUIs you could create a runtime that does not include the GUI modules significantly reducing the runtimes size Greater platform integrity Before Java 9 it was possible to use many classes in the platform that were not meant for use by an apps classes With strong encapsulation these internal
You must have JavaScript enabled to view digital editions.