{"id":13545962,"url":"https://github.com/tfesenko/Java-Modules-JPMS-CheatSheet","last_synced_at":"2025-04-02T17:32:24.000Z","repository":{"id":80972622,"uuid":"128988351","full_name":"tfesenko/Java-Modules-JPMS-CheatSheet","owner":"tfesenko","description":"Java Modules (JPMS) Cheatsheet","archived":false,"fork":false,"pushed_at":"2019-04-15T21:23:23.000Z","size":646,"stargazers_count":44,"open_issues_count":1,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-13T21:32:48.020Z","etag":null,"topics":["java9","java9-jigsaw","jigsaw","jpms","modularity","module"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tfesenko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-04-10T20:01:39.000Z","updated_at":"2025-01-30T01:31:06.000Z","dependencies_parsed_at":"2023-04-30T06:05:16.297Z","dependency_job_id":null,"html_url":"https://github.com/tfesenko/Java-Modules-JPMS-CheatSheet","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfesenko%2FJava-Modules-JPMS-CheatSheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfesenko%2FJava-Modules-JPMS-CheatSheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfesenko%2FJava-Modules-JPMS-CheatSheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfesenko%2FJava-Modules-JPMS-CheatSheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tfesenko","download_url":"https://codeload.github.com/tfesenko/Java-Modules-JPMS-CheatSheet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246860223,"owners_count":20845630,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java9","java9-jigsaw","jigsaw","jpms","modularity","module"],"created_at":"2024-08-01T12:00:28.927Z","updated_at":"2025-04-02T17:32:23.586Z","avatar_url":"https://github.com/tfesenko.png","language":null,"readme":"Java Modules (JPMS) Cheat Sheet\n========\n\nProject Jigsaw, The Java Platform Module System (JPMS), Modularity, JSR 277, JSR 376... These are the names of one of the most significant features of Java 9. Modularity reduces the complexity of the system by providing:\n* Explicit dependencies\n* Clear interface\n* Strong encapsulation\n\t\nModularity is also arguably one of the terrifying Java features of all times.  Despite these numerous benefits, proper modules are still rare species in the Java world. \n\nThe purpose of this cheat sheet is to show that modules in Java are friendly to us, developers, and easy to use. The [Module Declaration (module-info.java)](#module-declaration-module-infojava) section explains how to define modules. The [Module Path vs Class-Path](#module-path-vs-class-path) section will be helpful for people migrating existing non-modular applications to JPMS. \n\nTable of Contents\n-----------------\n[FAQ](#faq)  \n\n[Module Declaration (module-info.java)](#module-declaration-module-infojava)\n  * [Module Name and Minimal Module Declaration](#module-name-and-minimal-module-declaration)\n  * [Dependencies](#modules-dependencies)\n  * [API](#modules-api)\n  * Other Stuff: [Services](#optional-services-for-di), [Annotations](#annotations-in-module-declarations), and [Formal grammar of the module declaration file](#formal-grammar-of-the-module-declaration-file)\n\n[Module Path vs Class Path](#module-path-vs-class-path)\n  * [Types of Modules: Named and Unnamed](#types-of-modules-named-and-unnamed)\n  * [Explicit Modules](#explicit-modules)\n  * [Automatic Modules](#automatic-modules)\n  * [Unnamed Module](#unnamed-module)\n\n[Resources](#resources)\n\nFAQ\n========\nHere are some of important questions about support of old-style non-modular jar in Java 9+. It's better than what you think! :star2:\n\n### Will my plain old jar (without a module declaration) work? \n...and...\n### Will my modularized jar work with dependencies which are not modularized yet? \nYES! and YES! \nBut... if...:ballot_box_with_check:it's Java 9 friendly, *e.g.*, it doesn't use private API or split packages.  \n\nRead more:   \n:page_facing_up: Java 9 Migration Guide: The Seven Most Common Challenges: https://blog.codefx.org/java/java-9-migration-guide/  \n\nIn JPMS, you can convert existing non-modular jars into:\n* **Unnamed** modules, when passed on classpath;\n* Or, **automatic** modules, when passed on module path.  \nSee [Module Path vs Class Path](#module-path-vs-class-path).  \n\n\nModule Declaration (`module-info.java`)\n========\nA module declaration is a file which defines the dependency graph: \n* Dependencies: Which other modules this module depends on;\n* API: which parts of this module other modules can use: at compile time or at runtime.\n\nTo create a module declaration:  \n:heavy_check_mark: Create a file named `module-info.java`  \n:heavy_check_mark: By convention, it should be placed at the root source folder, e.g., next to the `com` or `org` folders.  \n\n![Module overview](./images/module_overview.png)\n\nModule Name and Minimal Module Declaration\n--------\nA minimal module declaration defines its name:\n```java\nmodule com.mycompany.myproject {\n}\n```\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e :bomb::boom: The module name must be \u003cb\u003eglobally unique\u003c/b\u003e - the name conflicts are prohibited. A recommended practice is to use a \u003cb\u003ereverse-domain-name pattern\u003c/b\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nModule's Dependencies\n--------\nDependencies are other modules this module needs for its work - it **requires** these modules.\n![dependency types](./images/dependency_types.png)\n\n```java\nmodule com.mycompany.myproject { // the module name should be unique\n\n   // dependency on `com.example.foo.bar` which must be present both at compile time AND runtime\n   requires com.example.foo.bar;\n   \n   // transitive dependency: any module which requires current module will also *implicitly* depend on this dependency\n   requires transitive com.kitties.bar;\n   \n   // optional dependency is mandatory at compile time, but optional at runtime \n   requires static com.owls.foo;\n}\n```\nRead more:   \n:page_facing_up: Optional Dependencies: https://blog.codefx.org/java/module-system-optional-dependencies/    \n:page_facing_up: Transitive Dependencies: https://blog.codefx.org/java/implied-readability/    \n\n\nModule's API\n--------\nIn pre-Java 9 world any public class was available everywhere and could be used by any other class. The \"internal\" packages were not in fact internal. With Java 9, module's contents are not available to the external classes by default; one must explicitly define what the module exposes to outside world so that other modules could use it either in compile time or via reflection. Module's API is now expressly specified in the module's declaration.\n\n\u003ctable\u003e\n\t\u003ctbody\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003cth colspan=\"2\" rowspan=\"2\"\u003e \u003c/th\u003e\n   \u003cth colspan=\"2\"\u003e\u003ch3\u003eCompile Access\u003c/h3\u003e\u003c/th\u003e\n   \u003cth colspan=\"2\"\u003e\u003ch3\u003eReflection Access\u003c/h3\u003e\u003c/th\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003cth\u003e\u003ch3\u003eWhat\u003c/h3\u003e\u003c/th\u003e\n   \u003cth\u003e\u003ch3\u003eBy Whom\u003c/h3\u003e\u003c/th\u003e\n \t\t\u003cth\u003e\u003ch3\u003eWhat\u003c/h3\u003e\u003c/th\u003e\n   \u003cth\u003e\u003ch3\u003eBy Whom\u003c/h3\u003e\u003c/th\u003e\n\t\t\u003c/tr\u003e  \n  \u003ctr\u003e\n\t\t\t\u003cth rowspan=\"2\"\u003e\u003ch3\u003eExport Package\u003c/h3\u003e\u003c/th\u003e\n\t\t\t\u003cth\u003e\u003ch3\u003eUnqualified\u003c/h3\u003e\u003c/th\u003e\n\t\t\t\u003ctd rowspan=\"2\"\u003e\u003cul\u003e\u003cli\u003e\u003cb\u003ePublic and protected types\u003c/b\u003e in the package\u003c/li\u003e\n\u003cli\u003e\u003cb\u003ePublic and protected members\u003c/b\u003e of those types\u003c/li\u003e\u003cul\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003eAll Code\u003c/td\u003e\n\t\t\t\u003ctd rowspan=\"2\"\u003e\u003cul\u003e\u003cli\u003e\u003cb\u003ePublic and protected types\u003c/b\u003e in the package\u003c/li\u003e\n\u003cli\u003e\u003cb\u003ePublic and protected members\u003c/b\u003e of those types\u003c/li\u003e\u003cul\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003eAll Code\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003cth\u003e\u003ch3\u003eQualified\u003c/h3\u003e\u003c/th\u003e\n\t\t\t\u003ctd\u003eModules from the \"to\" clause\u003c/td\u003e\n\t\t\t\u003ctd\u003eModules from the \"to\" clause\u003c/td\u003e\n\t\t\u003c/tr\u003e\n  \u003ctr\u003e\n\t\t\t\u003cth rowspan=\"2\"\u003e\u003ch3\u003eOpen Package\u003c/h3\u003e\u003c/th\u003e\n\t\t\t\u003cth\u003e\u003ch3\u003eUnqualified\u003c/h3\u003e\u003c/th\u003e\n\t\t\t\u003ctd rowspan=\"2\"\u003eNO access\u003c/td\u003e\n\t\t\t\u003ctd\u003eAll Code\u003c/td\u003e\n\t\t\t\u003ctd rowspan=\"2\"\u003e\u003cul\u003e\u003cli\u003e\u003cb\u003eAll\u003c/b\u003e types in the package\u003c/li\u003e\n\u003cli\u003eAnd \u003cb\u003eall\u003c/b\u003e their members\u003c/li\u003e\u003cul\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003eAll Code\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003cth\u003e\u003ch3\u003eQualified\u003c/h3\u003e\u003c/th\u003e\n\t\t\t\u003ctd\u003eModules from the \"to\" clause\u003c/td\u003e\n\t\t\t\u003ctd\u003eModules from the \"to\" clause\u003c/td\u003e\n\t\t\u003c/tr\u003e  \n \u003c/tbody\u003e\n\u003c/table\u003e\n\n\n### How to export or open a package\nA package can be exported or opened in\n* :smiley: Module declaration (`module-info.java` file). It's a recommended approach when you have control over this file.\n* :worried: Or, as a command line option, if you have no other choice.\n\u003ctable\u003e\n\t\u003ctbody\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003cth colspan=\"2\"\u003e \u003c/th\u003e\n   \u003cth\u003e\u003ch3\u003eModule Descriptor\u003c/h3\u003e\u003c/th\u003e\n   \u003cth\u003e\u003ch3\u003eJava Command Line Options\u003c/h3\u003e\u003c/th\u003e\n\t\t\u003c/tr\u003e\n   \u003ctr\u003e\n\t\t\t\u003cth rowspan=\"2\"\u003e\u003ch3\u003eExport Package\u003c/h3\u003e\u003c/th\u003e\n\t\t\t\u003cth\u003e\u003ch3\u003eUnqualified\u003c/h3\u003e\u003c/th\u003e\n\t   \t\t\u003ctd\u003e\u003ccode\u003eexports \u003cem\u003epackageName\u003c/em\u003e\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003en/a\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003cth\u003e\u003ch3\u003eQualified\u003c/h3\u003e\u003c/th\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003eexports \u003cem\u003epackageName\u003c/em\u003e to \u003cem\u003etargetModule\u003c/em\u003e\u003c/code\u003e\n\t\t\t\t\u003cbr/\u003e\u003cbr/\u003e\u003cem\u003e\u003cstrike\u003eALL-UNNAMED\u003c/strike\u003e\u003c/em\u003e is NOT allowed in the descriptor\u003c/td\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003e--add-exports \u003cem\u003esourceModule\u003c/em\u003e\u003cb\u003e/\u003c/b\u003e\u003cem\u003epackageName\u003c/em\u003e\u003cb\u003e=\u003c/b\u003e\u003cem\u003etargetModule(,targetModule)*\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/br/\u003e\n\tThe target-module can be \u003cem\u003eALL-UNNAMED\u003c/em\u003e to export to all unnamed modules\u003c/td\u003e\n\t\t\u003c/tr\u003e\n   \u003ctr\u003e\n\t\t\t\u003cth rowspan=\"2\"\u003e\u003ch3\u003eOpen Package\u003c/h3\u003e\u003c/th\u003e\n\t\t\t\u003cth\u003e\u003ch3\u003eUnqualified\u003c/h3\u003e\u003c/th\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003eopens \u003cem\u003epackageName\u003c/em\u003e\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003en/a\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003cth\u003e\u003ch3\u003eQualified\u003c/h3\u003e\u003c/th\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003eopens \u003cem\u003epackageName\u003c/em\u003e to \u003cem\u003etargetModule\u003c/em\u003e\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003e--add-opens \u003cem\u003esourceModule\u003c/em\u003e\u003cb\u003e/\u003c/b\u003e\u003cem\u003epackageName\u003c/em\u003e\u003cb\u003e=\u003c/b\u003e\u003cem\u003etargetModule(,targetModule)*\u003c/em\u003e\u003c/code\u003e\u003c/td\u003e\n\t\t\u003c/tr\u003e\n \u003c/tbody\u003e\n\u003c/table\u003e\n\nRead more:   \n:page_facing_up: Java Platform, Standard Edition Tools Reference \u003e Main Tools to Create and Build Applications \u003e java: https://docs.oracle.com/javase/9/tools/java.htm#GUID-3B1CE181-CD30-4178-9602-230B800D4FAE__GUID-AC22D7B8-E3C4-4554-AE49-A62C9421AA7C   \n:page_facing_up: Five Command Line Options To Hack The Java 9 Module System: https://blog.codefx.org/java/five-command-line-options-to-hack-the-java-9-module-system/   \n\n\n### Exported Packages\n\nThe `exports` directive defines what this module exposes to other modules at runtime and compile time.\n\n![Exported package](./images/export_package.png)\n```java\nmodule com.mycompany.myproject { // the module name should be unique\n\n   // unqualified export =\u003e grants access to ALL other modules\n   exports com.mycompany.myproject.foo;\n   \n   exports com.mycompany.myproject.foo.internal\n       // having a \"to\" clause means that this is a **qualified export** =\u003e exports the package only to the friends of the current module - the modules specified in the `to` clause\n       to com.example.x;\n   exports com.mycompany.myproject.bar.internal to com.example.y, com.example.z;\n          \n}   \n```\n\n### Packages Open for Reflection\nThe `opens` directive opens the module to the **outside** modules for the reflection. It's usually useful when using reflection-based frameworks such as Spring or Guice;\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e:pencil2: As for the code from \u003cb\u003einside\u003c/b\u003e of the current module, it can still reflectively access all types and members from the module regardless whether they were opened or not\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n![Open package](./images/open_package.png)\n```java\nmodule com.mycompany.myproject { // the module name should be unique\n   \n   // `opens` the package for reflection to ALL other modules\n   // * compile time: no access at all \n   // * runtime: to all types, including private types, and all their members, including private ones\n   opens com.mycompany.myproject.ollie;\n   \n   // a qualified `opens` directive - only modules from the `to` cause can access this package at runtime\n   opens com.mycompany.myproject.ollie.internal to org.anothercompany.coolframework;\n   \n   // Also see a section about the open modules - a module which opens ALL its packages\n}   \n```\n#### Shortcut: an **open** module\nAn open module `opens` all its packages. To define it, add the `open` modifier before the `module`:\n```java\nopen module com.mycompany.myproject {\n}   \n```\n\nAdvanced: Services for DI\n--------\nServices implemented with use of `ServiceLoader` existed in Java well before Java 9. Their goal is to do decouple the interface and its implementation(s). Now, in Java 9, we can declare services and their usages in the `module-info.java`:\nService consumer:\n```java\nmodule com.mycompany.serviceconsumer {\n   // Use an existing service. The implementation can be accessed in code by using the ServiceLoader\n   uses com.example.foo.ServiceInterface;\n}   \n```\nService provider:\n```java\nmodule com.mycompany.service {\n   // Register a new service implementation for com.example.foo.ServiceInterface\n   provides com.example.foo.ServiceInterface \n     with com.example.foo.ServiceImpl;\n}   \n```\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e :pencil2: Service consumer and service provider can also be defined in the same module.\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\nRead more:    \n:page_facing_up: https://dzone.com/articles/java-9-kickoff-project-jigsaw-and-serviceloader-part-2 \n\nAdvanced: Annotations in Module Declarations\n--------\nModule declarations can also have annotations, *e.g.*, the `@Deprecated` annotations:\n```\n/**\n * This module was replaced by a new module performing the same job much better!\n * @deprecated use {@link com.mycompany.newcoolmodule} instead.  \n */\n@Deprecated\nmodule com.mycompany.oldmodule {}\n```\n\nAdvanced: The formal grammar of the module declaration file\n--------\nOK, open modules, annotations... What else? :coffee: A structure of a module declaration may seem too complicated. But it's not! Just see the grammar for module files (taken from section 7.7 of [Java 9 Language Specification](http://cr.openjdk.java.net/~mr/jigsaw/spec/java-se-9-jls-diffs.pdf)):\n```yaml\nModuleDeclaration:\n  {Annotation} [open] module Identifier{.Identifier}\n  { {ModuleDirective} }\n\nModuleDirective:\n  requires {RequiresModifier} ModuleName ;\n  exports PackageName [to ModuleName {, ModuleName}] ; \n  opens PackageName [to ModuleName {, ModuleName}] ; \n  uses TypeName ;\n  provides TypeName with TypeName {, TypeName} ;\n\nRequiresModifier:\n  (one of)\n  transitive static\n  \nModuleName:\n  Identifier{.Identifier}\n```\n\nModule Path vs Class Path\n========\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003cth\u003e \u003c/th\u003e\n    \u003cth\u003e\u003ch3\u003eCommand line\u003c/h3\u003e\u003c/th\u003e\n    \u003cth\u003e\u003ch3\u003eModular JAR (JAR with a module-info.class)\u003c/h3\u003e\u003c/th\u003e\n    \u003cth\u003e\u003ch3\u003ePlain JAR\u003c/h3\u003e\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003cth\u003e\u003ch3\u003eModule Path\u003c/h3\u003e\u003c/th\u003e\n    \u003ctd\u003e\u003cul\u003e\u003cli\u003e\u003ccode\u003e--module-path modulepath\u003c/code\u003e\u003c/li\u003e\n\t    \u003cli\u003e\u003ccode\u003e-p modulepath\u003c/code\u003e\u003c/li\u003e\u003c/ul\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003cb\u003eExplicitly defined\u003c/b\u003e module\u003c/td\u003e\n    \u003ctd\u003e\u003cb\u003eAutomatic\u003c/b\u003e module\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003cth\u003e\u003ch3\u003eClasspath\u003c/h3\u003e\u003c/th\u003e\n    \u003ctd\u003e\u003cul\u003e\u003cli\u003e\u003ccode\u003e--class-path classpath\u003c/code\u003e\u003c/li\u003e\n\t    \u003cli\u003e\u003ccode\u003e-classpath classpath\u003c/code\u003e\u003c/li\u003e\n\t    \u003cli\u003e\u003ccode\u003e-cp classpath\u003c/code\u003e\u003c/li\u003e\n\t    \u003c/ul\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003cb\u003eUnnamed\u003c/b\u003e module\u003c/td\u003e\n    \u003ctd\u003e\u003cb\u003eUnnamed\u003c/b\u003e module\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\nYou can mix module path and classpath!\n\nRead more:  \n:page_facing_up: Java Platform, Standard Edition Tools Reference \u003e Main Tools to Create and Build Applications \u003e java: https://docs.oracle.com/javase/9/tools/java.htm#GUID-3B1CE181-CD30-4178-9602-230B800D4FAE__BABDJJFI\n\n\nTypes of Modules: Named and Unnamed\n--------\nAs you can see from the table above:\n* Everything on the module path, regardless whether it's a plain jar or a jar with a module-info, becomes a named module.\n* Similarly, everything on the classpath, regardless whether it's a plain jar or a jar with a module-info, becomes an unnamed module.\n\u003cimg src=\"./images/named_unnamed_module.png\" width=\"500\"\u003e\n\nIn fact, there are three module types:\n* Named:\n  * Explicit\n  * Automatic\n* Unnamed \n\n\u003cimg src=\"./images/module_types.png\" width=\"500\"\u003e\n\nExplicit Modules\n--------\nExplicit modules follow the rules for [Dependencies](#modules-dependencies) and [API](#modules-api) defined in its [Module Declaration (module-info.java)](#module-declaration-module-infojava)\n\t\nAutomatic Modules\n--------\nAutomatic modules are plain JARs (no module descriptor) on the module path.\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e :pencil2: \u003cb\u003ereads\u003c/b\u003e vs \u003cb\u003erequires\u003c/b\u003e\u003c/br\u003e\n\t\"Module1 reads Module2\" means that Module1 can access types from Module2's exported packages.\u003c/br\u003e\n\tA module that \u003cem\u003erequires\u003c/em\u003e another module also \u003cem\u003ereads\u003c/em\u003e the other module.\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nAs they don't have a `module-info.class`, this information will be calculated using the following rules:\n\n* **Name**: `Automatic-Module-Name` from `MANIFEST.MF` if it's present. Derived from the JAR name otherwise. \n  * They can be referenced using this name;\n  * See http://branchandbound.net/blog/java/2017/12/automatic-module-name/ for details;\n  * For Eclipse plug-ins, see https://dev.eclipse.org/mhonarc/lists/cross-project-issues-dev/msg14888.html;\n* **Dependencies**:\n  * It `requires transitive` all other resolved modules;\n  * Reads the [`unnamed` module](#unnamed-module);\n* **API**:\n  * Exports all its packages;\n  * The module can be referenced in other modules' `module-info.java` using its calculated name. \n\nUnnamed Module\n--------\nEverything on the classpath becomes an unnamed module.\n* ~**Name**~: No name;\n* **Dependencies**:\n  * Reads all other modules\n  * Can read or open other`ALL-UNNAMED` in the [command line](#how-to-export-or-open-a-package)\n* **API**:\n  * Because it does not have a name, it cannot be referenced in module-info.java.\n  * Readable only by [automatic modules](#automatic-modules)\n\n\n\nResources\n========\n:page_facing_up: Java Language Specification. Chapter 7. Packages and Modules. https://docs.oracle.com/javase/specs/jls/se9/html/jls-7.html  \n:books::heavy_dollar_sign: The Java Module System  by Nicolai Parlog : https://www.manning.com/books/the-java-module-system  \n\u003cb\u003eDisclaimer\u003c/b\u003e: I was a manuscript reviewer of this book and, thus, got a free copy of it from Manning.  \n\n:books::heavy_dollar_sign: Java 9 Modularity by Sander Mak, Paul Bakker: https://javamodularity.com/  \n:page_facing_up: Understanding Java 9 Modules: https://www.oracle.com/corporate/features/understanding-java-9-modules.html  \n:page_facing_up: Programming with Modularity and Project Jigsaw. A Tutorial Using the Latest Early Access Build https://www.infoq.com/articles/Latest-Project-Jigsaw-Usage-Tutorial  \n:speaker: Sander Mak on the Java Module System: https://www.infoq.com/podcasts/Sander-Mak-module-system-Java9  \n:movie_camera: Designing for Modularity with Java 9: https://www.youtube.com/watch?v=tamVhtV18dY  \n\nAcknowledgments\n=========\n* Special thanks to [Vera Zvereva](https://www.linkedin.com/in/verazvereva) whose feedback was invaluable. \n* https://github.com/ajaxorg/ace/pull/3628 \n\n\n","funding_links":[],"categories":["Articles"],"sub_categories":["Basics"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftfesenko%2FJava-Modules-JPMS-CheatSheet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftfesenko%2FJava-Modules-JPMS-CheatSheet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftfesenko%2FJava-Modules-JPMS-CheatSheet/lists"}