RFR: 8335989: Implement Module Import Declarations (Second Preview)

Jan Lahoda jlahoda at openjdk.org
Wed Oct 9 20:16:19 UTC 2024


This is a current patch for module imports declarations, second preview. At least the JEP number and preview revision will need to be updated in `jdk.internal.javac.PreviewFeature.Feature`, but otherwise I believe this is ready to receive feedback.

The main changes are:
- `requires transitive java.base;` is permitted, under the preview flag. Both javac and the runtime module system are updated to accept this directive when preview is enabled.
- the `java.se` module is using `requires transitive java.base;`, and is deemed to be participating in preview, so its classfile version is not tainted. Runtime is updated to access `requires transitive java.base;` in any `java.*`, considering all of them to be participating in preview. Can be tighten up to only `java.se` is desired.
- the types imported through module imports can be shadowed using on-demand imports. So, for example, having:

import module java.base;
import module java.desktop;
...
List l;//ambigous

but:

import module java.base;
import module java.desktop;
import java.util.*;
...
List l;//not ambigous, reference to java.util.List

-------------

Commit messages:
 - Cleanup.
 - Cleanup.
 - Fixing tests
 - Adding a separate scope for module imports.
 - Cleanup.
 - Make very sure java.base is completed.
 - Keep jdk.internal.javac qualified export from java.base.
 - Adding forgotten change.
 - java.se is participating in preview.
 - Adding forgotten change.
 - ... and 3 more: https://git.openjdk.org/jdk/compare/8c8f0d85...18554144

Changes: https://git.openjdk.org/jdk/pull/21431/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=21431&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8335989
  Stats: 707 lines in 26 files changed: 550 ins; 44 del; 113 mod
  Patch: https://git.openjdk.org/jdk/pull/21431.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/21431/head:pull/21431

PR: https://git.openjdk.org/jdk/pull/21431


More information about the build-dev mailing list