Giter Site home page Giter Site logo

learn-java-module's Introduction

Java 9 Modules

Concepts

  • modules are conceptually one level above a package
  • they tend to be at the same level as an individual .jar file that does not include other .jar files
  • modules specify dependency relationships among one another
  • modules specify which packages have their public types available to other modules that depend on them
  • modules have nothing at all to do with a versioning system, and they do not specify versions

Types of paths

  • class path
  • module path (defined by the host system)

Types of modules

modules

  • unnamed module (legacy)
    • code compiled by Java 9 that does not have a module descriptor and is not on the module path
    • reads all modules
    • readable by all automatic modules
    • not readable by modules
  • module (encapsulated)
    • code that has a module descriptor and is on the module path
    • reads modules it specifies with a "requires" declaration
    • readable by modules, if they declare it with their own "requires" declaration
    • readable by the unnamed module
    • may not read the unnamed module
    • legacy code can be incrementally converted to modules from the bottom up
    • represented as a regular .jar file with the addition of a module-info.class file at the root
  • automatic module (anarchy)
    • code that does not have a module descriptor, but is on the module path
    • reads all modules
    • reads the unnamed module
    • readable by modules, if they declare it with their own "requires" declaration
    • readable by all automatic modules
    • readable by the unnamed module
    • can be used as a bridge between modules and legacy code when bottom up conversion to modules is not practical
    • represented as a regular .jar file placed on a module path
    • the module name is derived from the name of the .jar file

Packages

  • Modules use "exports" declarations to indicate which packages are readable by other modules
  • Only public types are exported
  • It is a compile time error for two modules to export the same package
  • When a package can be loaded from either the module path or the class path, the module path is searched first
  • Apparent relationships between module names and package names have no significance with regards to behavior, it is convention only

Examples

dependency graph

Other details

  • jar has this option :-d, --describe-module Print the module descriptor, or automatic module name
  • Oracle's Java9 uses the non-standardized "jmod" format for modules, which includes support for native code

learn-java-module's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.