Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Java Platform Module System

From Wikipedia, the free encyclopedia
Distribution format for Java code and resources

TheJava Platform Module System[1] specifies a distribution format for collections ofJava code and associated resources. It also specifies a repository for storing these collections, ormodules, and identifies how they can be discovered, loaded and checked for integrity. It includes features such as namespaces with the aim of fixing some of the shortcomings in the existingJAR format, especially theJAR Hell, which can lead to issues such as classpath and class loading problems.

The Java Module System was initially being developed under theJava Community Process as JSR 277 and was scheduled to be released with Java 7.

JSR 277 later was put on hold and Project Jigsaw[2] was created to modularize the JDK. This JSR was superseded by JSR 376 (Java Platform Module System).

Project Jigsaw was originally intended forJava 7 (2011) but was deferred toJava 8 (2014) as part of Plan B,[3] and again deferred to aJava 9 release in 2017.[4] Java 9 including the Java Module System was released on September 21, 2017.[5]

Architecture

[edit]

The Java Module System implemented in Java 9 includes the followingJEPs andJSR (Java Specification Request):[2]

  • JEP 200: The Modular JDK: Define a modular structure for the JDK
  • JEP 201: Modular Source Code: Reorganize the JDK source code into modules, enhance the build system to compile modules, and enforce module boundaries at build time
  • JEP 220: Modular Run-Time Images: Restructure the JDK and JRE run-time images to accommodate modules and to improve performance, security, and maintainability
  • JEP 261: Module System: Implement the Java Platform Module System
  • JEP 282: The Java Linker: Create a tool that can assemble and optimize a set of modules and their dependencies into a custom run-time image[6]
  • JSR 376: Java Platform Module System[7]

Additionally, several other JDK 9 features have been added to ease transition to the module system:

  • JEP 238: Multi-Release JAR Files: Extend the JAR file format to allow multiple, Java-release-specific versions of class files to coexist in a single archive.[8]
  • JEP 253: PrepareJavaFX UI Controls & CSS APIs for Modularization: Define public APIs for the JavaFX functionalities that is presently only available via internal APIs and would become inaccessible due to modularization.[9]
  • JEP 260: Encapsulate Most Internal APIs: Make most of the JDK's internal APIs inaccessible by default but leave a few critical, widely-used internal APIs accessible, until supported replacements exist for all or most of their functionality.[10]
  • JEP 275: Modular Java Application Packaging: TheJava packager will evolve for JDK 9, making it aware of modules, allowing for example to package a module and all the modules it depends on.[11]

Properties of modules

[edit]

Modules are a new way of grouping code. Contrary toJar files, modules explicitly declare which modules they depend on, and what packages they export.[12] Explicit dependency declarations improve the integrity of the code, by making it easier to reason about large applications and the dependencies between software components.

The module declaration is placed in a file namedmodule-info.java at the root of the module’s source-file hierarchy. The JDK will verify dependencies and interactions between modules both at compile-time and runtime.

For example, the following module declaration declares that the modulecom.foo.bar depends on anothercom.foo.baz module, and exports the following packages:com.foo.bar.alpha andcom.foo.bar.beta:

modulecom.foo.bar{requirescom.foo.baz;exportscom.foo.bar.alpha;exportscom.foo.bar.beta;}

The public members ofcom.foo.bar.alpha andcom.foo.bar.beta packages will be accessible by dependent modules. Private members are inaccessible even through a means such asreflection. Note that inJava versions 9 through 16, whether such 'illegal access' isde facto permitted depends on a command line setting.[13]

The JDK itself has been modularized inJava 9.[14] For example, the majority of the Java standard library is exported by the modulejava.base.

Modules can themselves be imported, automatically importing all exported packages.[15] This is done usingimport module. For example,importmodulejava.sql; is equivalent to

importjava.sql.*;importjavax.sql.*;// Remaining indirect exports from java.logging, java.transaction.xa, and java.xml

Similarly,importmodulejava.base;, similarly, imports all 54 packages belonging tojava.base.

Modules use the followingkeywords:

  • exports: used in a module declaration to specify which packages are available to other modules
  • module: declares a module
  • open: indicates that all classes in a package are accessible via reflection by other modules
  • opens: used to open a specific package for reflection to other modules
  • provides: used to declare that a module provides an implementation of a service interface
  • requires: used in a module declaration to specify that the module depends on another module
  • to: used with theopens directive to specify which module is allowed to reflectively access the package
  • transitive: used with therequires directive to indicate that a module not only requires another module but also makes that module's dependencies available to modules that depend on it
  • uses: used in a module to declare that the module is using a service (i.e. it will consume a service provided by other modules)
  • with: used with theprovides directive to specify which implementation of a service is provided by the module

Core modules

[edit]

The modules under namespacejava.* belong to theJava Platform, Standard Edition, and modules under namespacejdk.* belong to theJava Development Kit.[16]

java.baseDefines the core APIs that form the foundation of the Java SE Platform.

Implicitly required by all modules and does not need to be declared withrequires inside a module declaration.

java.compilerDefines APIs related to the language model,Java annotation processing, and theJava compiler.
java.datatransferDefines the APIs that facilitate data transfer between applications or within an application.
java.desktopDefines theAbstract Window Toolkit (AWT) andSwing libraries for user interfaces, along with APIs for accessibility, audio, imaging, printing, andJavaBeans.
java.instrumentDefines services that allow for the instrumentation of programs running on theJava Virtual Machine (JVM).
java.loggingDefines the API forlogging events in Java applications (Java Logging API).
java.managementDefines the APIs for theJava Management Extensions (JMX) framework.
java.management.rmiDefines theRemote Method Invocation (RMI) connector for the Java Management Extensions (JMX) Remote API.
java.namingDefines the API forJava Naming and Directory Interface (JNDI) services.
java.net.httpDefines the API forHTTP client andWebSocket functionality.
java.prefsDefines the API for managing and storing user preferences.
java.rmiDefines the Remote Method Invocation (RMI) API for object communication across Java virtual machines.
java.scriptingDefines the API for integratingscripting engines into Java applications (Scripting API).
java.seDefines the standard API for the Java SE Platform.
java.security.jgssDefines the Java binding for theIETFGeneric Security Services API (GSS-API) for security contexts.
java.security.saslDefines Java's support for theSimple Authentication and Security Layer (SASL) protocol.
java.smartcardioDefines the API for interacting withsmart card devices (Java Smart Card I/O API).
java.sqlDefines theJava Database Connectivity (JDBC) API for database interaction.
java.sql.rowsetDefines the JDBC RowSet API for managing and interacting with tabular data in Java.
java.transaction.xaDefines an API for managing distributed transactions within JDBC.
java.xmlDefines theJava API for XML Processing (JAXP), including tools for parsing and transforming XML data.
java.xml.cryptoDefines the API forcryptographic operations with XML data.
jdk.accessibilityDefines utility classes for implementingAssistive Technologies in the JDK.
jdk.attachDefines the attach API for connecting to and interacting with a running JVM instance (attach API).
jdk.charsetsProvides additionalcharacter sets (charsets), including double-byte and IBM-specific charsets, not included injava.base.
jdk.compilerDefines the internal implementation of the Java compiler and the command-line tooljavac.
jdk.crypto.cryptokiDefines the implementation of the SunPKCS11 security provider for cryptographic operations.
jdk.dynalinkDefines the API for dynamically linking high-level operations on objects.
jdk.editpadImplements the edit pad service used byjdk.jshell for evaluating code.
jdk.hotspot.agentProvides the implementation for theHotSpot Serviceability Agent.
jdk.httpserverDefines the JDK-specific HTTP server API and thejwebserver tool for running a simple HTTP server.
jdk.incubator.vectorDefines the API for expressing computations that can be compiled into SIMD instructions at runtime, such as AVX or NEON instructions.
jdk.jartoolProvides tools for manipulatingJava Archive (JAR) files, such as thejar andjarsigner commands.
jdk.javadocDefines the system documentation tool implementation and its command-line version,javadoc.
jdk.jcmdDefines tools for diagnosing and troubleshooting JVM processes, includingjcmd,jps, andjstat.
jdk.jconsoleDefines the JMX-based graphical tool,jconsole, for monitoring and managing Java applications.
jdk.jdepsDefines tools for analysing dependencies in Java programs and libraries, such asjdeps,javap,jdeprscan, andjnativescan.
jdk.jdiDefines theJava Debug Interface (JDI) for debugging Java applications.
jdk.jdwp.agentProvides the implementation of theJava Debug Wire Protocol (JDWP) agent for remote debugging.
jdk.jfrDefines the API forJDK Flight Recorder (JFR) for collecting performance and diagnostic data.
jdk.jlinkDefines thejlink tool for creating custom runtime images, andjmod andjimage tools for managing JMOD and JDK container files.
jdk.jpackageDefines theJava packager tool (jpackage) for creating platform-specific application packages.
jdk.jshellProvides thejshell tool for interactively evaluating Java code snippets.
jdk.jsobjectDefines the API for integratingJavaScript objects in Java applications.
jdk.jstatdDefines thejstatd tool for remotely monitoring JVM statistics.
jdk.localedataProvides locale-specific data for non-US locales.
jdk.managementDefines JDK-specific management interfaces for JVM monitoring and control.
jdk.management.agentDefines the JMX-based management agent for the JVM.
jdk.management.jfrDefines the management interface for JDK Flight Recorder (JFR).
jdk.naming.dnsImplements theDNS Java Naming provider for resolving domain names.
jdk.naming.rmiImplements the RMI Java Naming provider for remote method invocation.
jdk.netDefines the JDK-specific API for network programming.
jdk.nio.mapmodeDefines specific file mapping modes available in the JDK.
jdk.sctpProvides the API forStream Control Transmission Protocol (SCTP) in the JDK.
jdk.security.authImplements authentication modules and security-related interfaces within thejavax.security.auth package (interfaces injavax.security.auth.*).
jdk.security.jgssDefines extensions to the GSS-API and the implementation of the SASL GSSAPI mechanism in the JDK.
jdk.xml.domDefines the JDK's subset of theWorld Wide Web Consortium (W3C)Document Object Model (DOM) API not covered by Java SE.
jdk.zipfsProvides the implementation for the ZIP file system provider, enabling access toZIP files as file systems.

Links with OSGi

[edit]

The Java Module System does not intend to support all the functionalities that theOSGi platform currently supports (for example the Life-Cycle model and the Services Registry). However the Java Module System will support functions which are not supported by OSGi, such as modularity at compile-time, and built-in support for native libraries.[17] A couple of articles exploring how the Java Module System and OSGi could interoperate were published in 2016. These can be found on InfoQ[18] and also the OSGi Alliance Blog.[19]

See also

[edit]

References

[edit]
  1. ^"Java Platform Module System (JSR 376)".Oracle Corporation. Retrieved2018-07-02.
  2. ^ab"Project Jigsaw".Oracle Corporation. Retrieved2015-11-29.
  3. ^Mark Reinhold (2009-09-20)."It's time for … Plan B".Oracle Corporation. Retrieved2017-06-21.
  4. ^"JDK 9".Oracle Corporation. Retrieved2016-02-24.
  5. ^"Java 9: Release date and new features". techworld.com. 2017-07-21. Retrieved2017-11-18.
  6. ^"jlink: The Java Linker (JSR 282)".Oracle Corporation. Retrieved2016-03-12.
  7. ^"Java Platform Module System (JSR 376)".Oracle Corporation. Retrieved2015-11-29.
  8. ^"JEP 238: Multi-Release JAR Files".Oracle Corporation. Retrieved2017-07-31.
  9. ^"JEP 253: Prepare JavaFX UI Controls & CSS APIs for Modularization".Oracle Corporation. Retrieved2017-07-31.
  10. ^"JEP 260: Encapsulate Most Internal APIs".Oracle Corporation. Retrieved2017-07-31.
  11. ^"JEP 275: Modular Java Application Packaging".Oracle Corporation. Retrieved2017-07-31.
  12. ^Mark Reinhold (2016-03-08)."The State of the Module System".Oracle Corporation. Retrieved2017-02-18.
  13. ^"JEP 396: Strongly Encapsulate JDK Internals by Default". Retrieved2021-02-06.
  14. ^"JDK Module Summary".Oracle Corporation. 2016-06-24. Archived fromthe original on 2015-12-08. Retrieved2017-02-18.
  15. ^"JEP 494: Module Import Declarations (Second Preview)".openjdk.org.
  16. ^"Java® Platform, Standard Edition & Java Development Kit Version 24 API Specification".docs.oracle.com.
  17. ^Mark Reinhold (2012-08-24)."Project Jigsaw: Late for the train: The Q&A".Oracle Corporation. Retrieved2015-11-29.
  18. ^"Java 9, OSGi and the Future of Modularity". InfoQ. Retrieved2016-09-26.
  19. ^"Java Module Layers and OSGi Bundles". OSGi Alliance. Retrieved2016-08-01.

External links

[edit]
Platforms
Technologies
Oracle
Platform
Major
third-party
History
JVM
languages
Community
Conferences
Organizations
People
Retrieved from "https://en.wikipedia.org/w/index.php?title=Java_Platform_Module_System&oldid=1293636058"
Category:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp