Summary
Enhance the Java language with a new types of imports - an import that can import all exported packages from a module. The main goal is to aid beginner programers.
Problem
In order to write a simple program, beginner programmers must often import classes from multiple packages - like java.io
and java.util
. This is distracting them from their goal at hand, and creates obstacles in learning Java.
Solution
We propose that a new type of imports is added to the Java language. This new import would import all the packages exported from a given module.
For example:
import module M;
Should import all packages exported to the current module from M
and its transitive dependencies as if they were imported using the type-on-demand imports for the respective packages.
Some relevant adjustments to the Trees API and JShell API are needed as well.
Specification
The current draft JLS changes is attached as a pdf.
The specdiff for the API changes is attached as specdiff.00.zip, and also available for convenience here: https://cr.openjdk.org/~jlahoda/8328481/specdiff.00/overview-summary.html
This is a preview language feature.
- csr of
-
JDK-8328481 Implement JEP 476: Module Import Declarations (Preview)
- Resolved
- relates to
-
JDK-8315129 JEP 476: Module Import Declarations (Preview)
- Closed