Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8328935

Implement Module Imports

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 23
    • tools
    • None
    • source
    • minimal
    • Language construct
    • SE

      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.

        1. 2024.04.18 Module Import Declarations (Preview).pdf
          273 kB
          Gavin Bierman
        2. Module Import Declarations (Preview).pdf
          268 kB
          Gavin Bierman

            jlahoda Jan Lahoda
            jlahoda Jan Lahoda
            Vicente Arturo Romero Zaldivar
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: