Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8328481: Implement JEP 476: Module Import Declarations (Preview) #18614

Closed
wants to merge 28 commits into from

Conversation

lahodaj
Copy link
Contributor

@lahodaj lahodaj commented Apr 4, 2024

This is an implementation of JEP JDK-8315129: Module Import Declarations (Preview). Please see the JEP for details:
https://bugs.openjdk.org/browse/JDK-8315129

It is mostly straightforward - the module imports are parsed, and then expanded to import-on-demand in TypeEnter.
There is a few notable aspects, however:

  • the AST node for import (JCImport) is holding the imported element as a field access, because so far, the imported element always had to have a '.' (even for import-on-demand). But for module imports, it is permissible to import from a module whose name does not have a dot (import module m;). The use of field access for ordinary import seems very useful, so I preferred to keep that, and created a new internal-only AST node for module imports. There is still only one public API AST node/interface, so this is purely an implementation choice.
  • JShell now supports module imports as well; and the default, implicit, script is changed to use it to import all of java.base if preview is enabled. It is expected that the default would be changed if/when the module imports feature is finalized.

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change requires CSR request JDK-8328935 to be approved

Issues

  • JDK-8328481: Implement JEP 476: Module Import Declarations (Preview) (Sub-task - P4)
  • JDK-8328935: Implement Module Imports (CSR)

Reviewers

Contributors

  • Jim Laskey <jlaskey@openjdk.org>

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/18614/head:pull/18614
$ git checkout pull/18614

Update a local copy of the PR:
$ git checkout pull/18614
$ git pull https://git.openjdk.org/jdk.git pull/18614/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 18614

View PR using the GUI difftool:
$ git pr show -t 18614

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/18614.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 4, 2024

👋 Welcome back jlahoda! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Apr 4, 2024

@lahodaj This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8328481: Implement JEP 476: Module Import Declarations (Preview)

Co-authored-by: Jim Laskey <jlaskey@openjdk.org>
Reviewed-by: mcimadamore, vromero

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 63 new commits pushed to the master branch:

  • 553d45b: 8323724: Remove potential re-inflation from FastHashCode under LM_LIGHTWEIGHT
  • dd0b641: 8330813: Don't call methods from Compressed(Oops|Klass) if the associated mode is inactive
  • 389f6fe: 8331344: No compiler replay file with CompilerCommand MemLimit
  • a024eed: 8331478: JFR: Rename printHelp methods for jdk.jfr.internal.dcmd classes
  • 9912abf: 8331011: [XWayland] TokenStorage fails under Security Manager
  • 257a07d: 8331511: Tests should not use the "Classpath" exception form of the legal header
  • c21672d: 8331077: nroff man page update for jar tool
  • cccc953: 8329258: TailCall should not use frame pointer register for jump target
  • 4a78906: 8331537: Test code should not use the "Classpath" exception clause
  • 2056968: 8331513: Tests should not use the "Classpath" exception form of the legal header
  • ... and 53 more: https://git.openjdk.org/jdk/compare/4e5c25ee43d4ec31ed5160fd93a2fd15e35182f8...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk
Copy link

openjdk bot commented Apr 4, 2024

⚠️ @lahodaj This pull request contains merges that bring in commits not present in the target repository. Since this is not a "merge style" pull request, these changes will be squashed when this pull request in integrated. If this is your intention, then please ignore this message. If you want to preserve the commit structure, you must change the title of this pull request to Merge <project>:<branch> where <project> is the name of another project in the OpenJDK organization (for example Merge jdk:master).

@openjdk openjdk bot added the rfr Pull request is ready for review label Apr 4, 2024
@openjdk
Copy link

openjdk bot commented Apr 4, 2024

@lahodaj The following labels will be automatically applied to this pull request:

  • compiler
  • core-libs
  • kulla

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added core-libs core-libs-dev@openjdk.org compiler compiler-dev@openjdk.org kulla kulla-dev@openjdk.org labels Apr 4, 2024
@mlbridge
Copy link

mlbridge bot commented Apr 4, 2024

@lahodaj
Copy link
Contributor Author

lahodaj commented Apr 4, 2024

/contributor add jlaskey

@openjdk
Copy link

openjdk bot commented Apr 4, 2024

@lahodaj
Contributor Jim Laskey <jlaskey@openjdk.org> successfully added.

@lahodaj lahodaj changed the title 8328935: Implement Module Imports. 8328481: Implement Module Imports. Apr 4, 2024
@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label Apr 4, 2024
@lahodaj lahodaj changed the title 8328481: Implement Module Imports. 8328481: Implement Module Imports Apr 4, 2024
@Thihup
Copy link
Contributor

Thihup commented Apr 4, 2024

Should the pull request incorporate a modification to the JAVASE script file for JShell, specifically substituting it with import module java.se? (right now the imports are computed, not read from a file)


# 0: symbol
compiler.err.import.module.does.not.read=\
current modules does not read: {0}
Copy link
Member

@sormuras sormuras Apr 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
current modules does not read: {0}
current module does not read: {0}

It would even be better to print the name of the "current" module, so that the user-facing message reads:
current module foo does not read module bar - possible fix: add "requires bar;" to foo's module descriptor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I've tweaked the error to include the module name here:
7cfaff8

Regarding possible fix(es) - it may be better to introduce some framework for that, and convert the most typical errors, separately. (As I don't think we do that for other errors.)

*/
public static class JCModuleImport extends JCImportBase {
/** The module name. */
public JCExpression module;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it need to be an expression? Or is a name enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expression is more consistent with e.g. the module directives (JCRequires has JCExpression moduleName). Also allows us to keep positions for the name.

@@ -81,6 +81,8 @@ public enum Feature {
CLASSFILE_API,
@JEP(number=461, title="Stream Gatherers", status="Preview")
STREAM_GATHERERS,
@JEP(number=0, title="Module Imports", status="Preview")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this has been assigned JEP 476 so I assume you can set the number for the first integration.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks:
432393a


# 0: symbol, 1: symbol
compiler.err.import.module.does.not.read=\
{1} module does not read: {0}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be module {1} does not read: {0} ? Also, maybe worth reordering the params?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Fixed:
846b038

* @since 23
*/
@PreviewFeature(feature=PreviewFeature.Feature.MODULE_IMPORTS, reflective=true)
boolean isModule();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are not including any test that stresses this new method

Copy link
Contributor

@vicente-romero-oracle vicente-romero-oracle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks!

@openjdk openjdk bot added ready Pull request is ready to be integrated and removed csr Pull request needs approved CSR before integration labels Apr 26, 2024
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label May 2, 2024
@lahodaj lahodaj changed the title 8328481: Implement Module Imports 8328481: Implement JEP 476: Module Import Declarations (Preview) May 2, 2024
@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 2, 2024
@lahodaj
Copy link
Contributor Author

lahodaj commented May 6, 2024

/integrate

@openjdk
Copy link

openjdk bot commented May 6, 2024

Going to push as commit f2c4a41.
Since your change was applied there have been 98 commits pushed to the master branch:

  • 9347bb7: 8330247: C2: CTW fail with assert(adr_t->is_known_instance_field()) failed: instance required
  • b20fa7b: 8329982: compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleDebugInfoTest.java failed assert(oopDesc::is_oop_or_null(val)) failed: bad oop found
  • c1a1645: 8331655: ClassFile API ClassCastException with verbose output of certain class files
  • 36c9607: 8331591: sun.font.CharSequenceCodePointIterator is buggy and unused
  • b33096f: 8295153: java/util/Base64/TestEncodingDecodingLength.java ran out of memory
  • cf2c80e: 8331582: Incorrect default Console provider comment
  • 77b7122: 8312104: Update java man pages to include new security category in -XshowSettings
  • 87bb66c: 8331569: G1: Rename G1HRPrinter to G1HeapRegionPrinter
  • 37c2469: 8331633: Use MIN2 in bound_minus_alignment
  • 1d083eb: 8331562: G1: Remove API to force allocation of new regions
  • ... and 88 more: https://git.openjdk.org/jdk/compare/4e5c25ee43d4ec31ed5160fd93a2fd15e35182f8...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label May 6, 2024
@openjdk openjdk bot closed this May 6, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels May 6, 2024
@openjdk
Copy link

openjdk bot commented May 6, 2024

@lahodaj Pushed as commit f2c4a41.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler compiler-dev@openjdk.org core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated kulla kulla-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

6 participants