-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Conversation
👋 Welcome back jlahoda! A progress list of the required criteria for merging this PR into |
@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:
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
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 |
|
Webrevs
|
/contributor add jlaskey |
@lahodaj |
Should the pull request incorporate a modification to the JAVASE script file for JShell, specifically substituting it with |
|
||
# 0: symbol | ||
compiler.err.import.module.does.not.read=\ | ||
current modules does not read: {0} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thanks!
/integrate |
Going to push as commit f2c4a41.
Your commit was automatically rebased without conflicts. |
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:
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.java.base
if preview is enabled. It is expected that the default would be changed if/when the module imports feature is finalized.Progress
Issues
Reviewers
Contributors
<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