Tuesday 24 November 2015

JavaOne 2015: Project Jigsaw: Under the Hood

Winding down day 2, we really pick up the intensity. The under the hood session on Jigsaw was one of the top sessions in terms of technical depth and knowledge sharing. If you're interested in the nuts and bolts of how modules will function in JDK9, this is a definite one to watch.

Here is a brief overview of the session.
  • Module Based Classloader
  • Strong encapsulation
  • Explicit readability
  • Modules must explicitly export and import the packages and classes to maintain readability
  • A public class no longer implies accessibility across barriers
  • Readability defined accessibility
src/com.example.package/module-info.java
    module com.eample.package {
          exports com.example.package.data
          exports com.example.package.services
    }
  • Independent of classloading and enforceable at compile time, in JVM and through reflection
  • Three types of modules to achieve smooth migration and backward compatibility
    • Explicit
      • Explicitly created JDK9 module
      • Well defined export / import for read edges
    • Automatic
      • Implicit module
      • Exports all
      • Reads from JDK and unnamed module
      • Modules named after JARs
    • Unnamed
      • Akin to the classpath
      • May read any exported prckage or class
      • Exports all
      • Reads none
      • Holds JARs only
  • No classloader changes, modules are associated to the base 3 classloaders
  • Classloaders always respect the module graph
  • Layers - Control the relationship of classloaders to modules
    • Creates a hierarchical module graph
    • Guarantees no cycles
  • Only 1 module may export a package (no split packaging)
  • Loader may only have 1 class of the same name

No comments:

Post a Comment