Java:Module

来自WHY42

Java Platform Module System (JPMS)是Java9中的最大的变动,在376: JavaTM Platform Module System中引入。

基本原理

首先,模块化的jar文件(Modular JAR)中需要一个module-info.class文件,这个文件里面存储了模块的信息。倘若没有,那么认为这是一个automatic module,也即用jar的文件名作为模块来导出。

除此之外,jar文件中通过目录存储安全、版本等其他信息

  • MANIFEST.MF:定义package相关信息
  • INDEX.LIST:This file is generated by the new "-i" option of the jar tool, which contains location information for packages defined in an application. It is part of the JarIndex implementation and used by class loaders to speed up their class loading process.
  • The signature file for the JAR file. 'x' stands for the base file name.
  • x.DSA:The signature block file associated with the signature file with the same base file name. This file stores the digital signature of the corresponding signature file.
  • services/:This directory stores all the service provider configuration files.

JDK模块

❯❯❯ java --list-modules
java.base@11.0.9
java.compiler@11.0.9
java.datatransfer@11.0.9
java.desktop@11.0.9
java.instrument@11.0.9
java.logging@11.0.9
java.management@11.0.9
java.management.rmi@11.0.9
java.naming@11.0.9
java.net.http@11.0.9
java.prefs@11.0.9
java.rmi@11.0.9
java.scripting@11.0.9
java.se@11.0.9
java.security.jgss@11.0.9
java.security.sasl@11.0.9
java.smartcardio@11.0.9
java.sql@11.0.9
java.sql.rowset@11.0.9
java.transaction.xa@11.0.9
java.xml@11.0.9
java.xml.crypto@11.0.9
jdk.accessibility@11.0.9
jdk.aot@11.0.9
jdk.attach@11.0.9
jdk.charsets@11.0.9
jdk.compiler@11.0.9
jdk.crypto.cryptoki@11.0.9
jdk.crypto.ec@11.0.9
jdk.dynalink@11.0.9
jdk.editpad@11.0.9
jdk.hotspot.agent@11.0.9
jdk.httpserver@11.0.9
jdk.internal.ed@11.0.9
jdk.internal.jvmstat@11.0.9
jdk.internal.le@11.0.9
jdk.internal.opt@11.0.9
jdk.internal.vm.ci@11.0.9
jdk.internal.vm.compiler@11.0.9
jdk.internal.vm.compiler.management@11.0.9
jdk.jartool@11.0.9
jdk.javadoc@11.0.9
jdk.jcmd@11.0.9
jdk.jconsole@11.0.9
jdk.jdeps@11.0.9
jdk.jdi@11.0.9
jdk.jdwp.agent@11.0.9
jdk.jfr@11.0.9
jdk.jlink@11.0.9
jdk.jshell@11.0.9
jdk.jsobject@11.0.9
jdk.jstatd@11.0.9
jdk.localedata@11.0.9
jdk.management@11.0.9
jdk.management.agent@11.0.9
jdk.management.jfr@11.0.9
jdk.naming.dns@11.0.9
jdk.naming.ldap@11.0.9
jdk.naming.rmi@11.0.9
jdk.net@11.0.9
jdk.pack@11.0.9
jdk.rmic@11.0.9
jdk.scripting.nashorn@11.0.9
jdk.scripting.nashorn.shell@11.0.9
jdk.sctp@11.0.9
jdk.security.auth@11.0.9
jdk.security.jgss@11.0.9
jdk.unsupported@11.0.9
jdk.unsupported.desktop@11.0.9
jdk.xml.dom@11.0.9
jdk.zipfs@11.0.9