Summary
We propose to finalize the module import declarations feature. There are no non-editorial change to the specifications.
Problem
The module import declarations feature have been through two rounds of preview. The experience suggests we can make the feature final and permanent.
Solution
The following will happen for finalization of this feature:
- the preview addendums for the JLS and JVMS will be folded into the corresponding main, non-preview specifications, mostly as is. Specifications will undergo editorial changes.
- javac will no longer require
--enable-previewcommand line option for the use ofimport module <module-name>;andrequires transitive java.base;. - both javac and the JDK runtime will accept
module-infoclassfiles withrequires transitive java.base;. - relevant API methods currently marked with
@PreviewFeaturewill be made final and permanent by removing this annotation - the default startup script for JShell will be adjusted based on the current JShell's behavior when
--enable-previewis specified
Specification
The use of import module ... and requires transitive java.base; in source code will no longer require --enable-preview from Java compilers.
The use of the requires transitive java.base; directive in module-info.class will no longer require --enable-preview, at compile time and at runtime.
The current copies of the JLS and JVMS drafts are attached.
A specdiff showing the API changes is attached and also available for convenience here: https://cr.openjdk.org/~jlahoda/JDK-8344708/specdiff.00/overview-summary.html
JShell
The default startup script for JShell currently differs depending on whether the --enable-preview command line option is used.
If the --enable-preview command line option is not used, the default script lists a hard-coded list of packages. If the --enable-preview command line option is used, the JShell's default startup script is:
import module java.base;
import static java.io.IO.*;
This will be changed as follows:
When there's no --enable-preview command line option and source level is greater of equal to 25:
The default startup script will be:
import module java.base;
When there's the --enable-preview command line option:
Until https://openjdk.org/jeps/8344699 is integrated, the default startup script will be:
import module java.base;
import static java.io.IO.*;
When https://openjdk.org/jeps/8344699 is integrated, the default startup script will be:
import module java.base;
When source level is lower than 25:
The default startup script will be:
import java.io.*;
import java.math.*;
import java.net.*;
import java.nio.file.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.prefs.*;
import java.util.regex.*;
import java.util.stream.*;
Which is the current default without the --enable-preview command line option.
- csr of
-
JDK-8344708 Implement JEP 511: Module Import Declarations
-
- Resolved
-
- relates to
-
JDK-8341865 Implement Module Import Declarations (Second Preview)
-
- Closed
-
-
JDK-8046172 JEP 182: Policy for Retiring javac -source and -target Options
-
- Draft
-