The Java SE Development Kit 9 has so many features added, but the biggest one is the Java Platform Module System (JSR 376). .. Since it is explained on various sites [^ 1], I will not describe what this is like here, but I would like to deepen my understanding while looking at actual examples.
[^ 1]: As an example → https://www.slideshare.net/skrb/introduction-of-project-jigsaw
After all, the source that comes with the JDK is the best. In the Windows version of Oracle JDK 9, it seems to be in C: \ Program Files \ Java \ jdk-9.0.1 \ lib \ src.zip
by default. Expand this to see.
(Previously it wasn't under lib
, so it's changed)
Up to JDK 8, the contents of src.zip
suddenly had a folder for Java packages, but in JDK 9, there is a folder for modules first, and under that there is a folder for module-info.java
and Java packages.
C:\Java\JDKsrc>dir /b 1.8.0_131
com
java
javax
launcher
org
C:\Java\JDKsrc>dir /b 9.0.1
java.activation
java.base
java.compiler
java.corba
java.datatransfer
java.desktop
java.instrument
java.logging
java.management
java.management.rmi
java.naming
java.prefs
java.rmi
java.scripting
java.se
java.se.ee
java.security.jgss
java.security.sasl
java.smartcardio
java.sql
java.sql.rowset
java.transaction
java.xml
java.xml.bind
java.xml.crypto
java.xml.ws
java.xml.ws.annotation
javafx.base
javafx.controls
javafx.fxml
javafx.graphics
javafx.media
javafx.swing
javafx.web
jdk.accessibility
jdk.attach
jdk.charsets
jdk.compiler
jdk.crypto.cryptoki
jdk.crypto.ec
jdk.crypto.mscapi
jdk.dynalink
jdk.editpad
jdk.hotspot.agent
jdk.httpserver
jdk.incubator.httpclient
jdk.internal.ed
jdk.internal.jvmstat
jdk.internal.le
jdk.internal.opt
jdk.internal.vm.ci
jdk.jartool
jdk.javadoc
jdk.jcmd
jdk.jconsole
jdk.jdeps
jdk.jdi
jdk.jdwp.agent
jdk.jlink
jdk.jshell
jdk.jsobject
jdk.jstatd
jdk.localedata
jdk.management
jdk.management.agent
jdk.naming.dns
jdk.naming.rmi
jdk.net
jdk.pack
jdk.packager
jdk.packager.services
jdk.policytool
jdk.rmic
jdk.scripting.nashorn
jdk.scripting.nashorn.shell
jdk.sctp
jdk.security.auth
jdk.security.jgss
jdk.unsupported
jdk.xml.bind
jdk.xml.dom
jdk.xml.ws
jdk.zipfs
C:\Java\JDKsrc>
Let's take a look at one.
C:\Java\JDKsrc>dir /b 9.0.1\java.activation
com
javax
module-info.java
C:\Java\JDKsrc>
It's like this.
Well, the more I say it (the more I open it), the more I feel.
Anyway, it's the new module-info.java
. I will read this. Since it's a big deal, let's take a look at the one in java.base
.
The first is a comment such as the usual Copyright, and then there is a comment part that starts with / **
like the API document. In this, a tag that I have never seen before is used.
You can rely on Java Platform, Standard Edition Javadoc Guide Release 9 to understand the meaning.
tag | Concrete example | meaning | JDK Bug System |
---|---|---|---|
@index |
{@index jrt jrt} |
javadoc Register words and phrases that are indexed by the tool. |
JDK-8144287 |
@extLink |
{@extLink keytool_tool_reference keytool} |
Reference to external documentation. | JDK-8178725 |
@provides |
@provides java.nio.file.spi.FileSystemProvider |
@provides Declaration of using |
JDK-8160196 |
@uses |
@uses java.lang.System.LoggerFinder |
@uses Declaration of using |
Same as above |
@moduleGraph |
@moduleGraph |
Module subgraph | JDK-8173303 |
I don't know if this is all the newly added tags, but these are the 5 newest in module-info.java
of java.base
.
@moduleGraph
is displayed in API documentation for java.base. Hmmmmmm I see.
exports java.io;
And,
exports jdk.internal.jmod to
jdk.compiler,
jdk.jlink;
Feeling like that. ʻExport` When there is only one destination
exports sun.util.resources to jdk.localedata;
It seems that it is written in one line like. Regarding the operation of ʻexports`, summary of directives of module-info.java is easy to understand.
At the end
uses sun.util.spi.CalendarProvider;
provides java.nio.file.spi.FileSystemProvider with jdk.internal.jrtfs.JrtFileSystemProvider;
}
It ends with.
I think the same blog Using SPI with Jigsaw is easy to understand for ʻusesand
provides`.
Recommended Posts