I read module-info.java in java.base

Where to touch the new features

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

Speaking of examples

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)

That? Isn't it funny?

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.

Try to read

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.

There are comments like API documentation

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} javadocRegister 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 @providesDeclaration of using JDK-8160196
@uses @uses java.lang.System.LoggerFinder @usesDeclaration 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.

After that, the module definition is in a row

    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 ʻusesandprovides`.

Recommended Posts

I read module-info.java in java.base
Read JSON in Java
Read binary files in Java 1
I can read it! RxJava
Read design patterns in Ruby
I made roulette in Java.
I got stuck in File
Read standard input in Java
Read binary files in Java 2
I read the Kotlin startbook
I tried node-jt400 (IFS read)
I tried metaprogramming in Java
I participated in Kubernetes Internal # 2
I read "7 Design Patterns to Refactor MVC Components in Rails" (writing)
I sent an email in Java
Easily read text files in Java (Java 11 & Java 7)
Read Java properties file in C #
I participated in JJUG CCC 2019 Spring
I read the source of ArrayList I read
Read CSV in Java (Super CSV Annotation)
I read the source of Integer
I wrote Goldbach's theorem in java
I tried putting Domino11 in CentOS7
I read the source of Long
I participated in JJUG CCC 2019 fall
I made an annotation in Java.
I tried using JWT in Java
I read the source of Short
I read the source of Byte
I read the source of String
I participated in JJUG CCC 2019 Fall.