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

8317620: Build JDK tools with ModuleMainClass attribute #16463

Closed
wants to merge 2 commits into from

Conversation

mlchung
Copy link
Member

@mlchung mlchung commented Nov 1, 2023

Tool modules can be created via jmod --main-class option such that ModuleMainClass attribute will be added in module-info.class and the module's main class can be launched via java -m <module-name> without specifying the name of the main class.

In addition, for modules with ModuleMainClass attribute, jlink will pre-resolve the module graph such that when such module is launched at runtime (without --add-modules or --limit-modules option), the runtime can skip the module resolution and speed up the startup time.

This PR extends the build system to allow a module to specify the main class under make/modules/$MODULE/Jmod.gmk file. Also JDK tools with a single entry point (or a primary entry point) are candidates to add ModuleMainClass attribute in module-info.class to benefit from the jlink optimization. For example, java -m jdk.jpackage will be launched using the pre-resolved module graph.

Verified manually by running java -m $MODULE on the modules with main class.


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

Issue

  • JDK-8317620: Build JDK tools with ModuleMainClass attribute (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 16463

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 1, 2023

👋 Welcome back mchung! 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 openjdk bot added the rfr Pull request is ready for review label Nov 1, 2023
@openjdk
Copy link

openjdk bot commented Nov 1, 2023

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

  • build
  • hotspot-jfr
  • 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 build build-dev@openjdk.org kulla kulla-dev@openjdk.org hotspot-jfr hotspot-jfr-dev@openjdk.org labels Nov 1, 2023
@mlchung
Copy link
Member Author

mlchung commented Nov 1, 2023

/label remove kulla
/label remove hotspot-jfr

@openjdk openjdk bot removed the kulla kulla-dev@openjdk.org label Nov 1, 2023
@openjdk
Copy link

openjdk bot commented Nov 1, 2023

@mlchung
The kulla label was successfully removed.

@mlchung
Copy link
Member Author

mlchung commented Nov 1, 2023

/label remove hotspot-jfr

@openjdk openjdk bot removed the hotspot-jfr hotspot-jfr-dev@openjdk.org label Nov 1, 2023
@openjdk
Copy link

openjdk bot commented Nov 1, 2023

@mlchung
The hotspot-jfr label was successfully removed.

@openjdk
Copy link

openjdk bot commented Nov 1, 2023

@mlchung The hotspot-jfr label was not set.

@mlbridge
Copy link

mlbridge bot commented Nov 1, 2023

Webrevs

# questions.
#

JMOD_FLAGS_main_class := --main-class com.sun.tools.example.debug.tty.TTY
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure about this one. Every few years there is a suggestion to deprecate or remove jdb. It's the example debugger from the original JPDA effort in the JDK 1.2 timeframe and hasn't really developed much since then. The main reason is stays around is that it is needed by our tests, and some people say it's useful to have something in production environments where the main stream debuggers can't go. I'm not opposed to "java -m jdk.jdi", it's just that this is a legacy/example tool that isn't the main focus of the jdk.jdi module.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can share the same concern. I will take this out.

Copy link
Member

@erikj79 erikj79 left a comment

Choose a reason for hiding this comment

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

Looks ok from a build point of view.

make/Main.gmk Outdated
Comment on lines 408 to 410
+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) \
$(patsubst %,-I%/modules/$1,$(PHASE_MAKEDIRS)) \
-f CreateJmods.gmk MODULE=$1)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) \
$(patsubst %,-I%/modules/$1,$(PHASE_MAKEDIRS)) \
-f CreateJmods.gmk MODULE=$1)
+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) \
$(patsubst %,-I%/modules/$1,$(PHASE_MAKEDIRS)) \
-f CreateJmods.gmk MODULE=$1)

@openjdk
Copy link

openjdk bot commented Nov 2, 2023

@mlchung 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:

8317620: Build JDK tools with ModuleMainClass attribute

Reviewed-by: erikj, alanb

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 17 new commits pushed to the master branch:

  • e318cd2: 8316969: Improve CDS module graph support for --module option
  • 7a7b1e5: 8315890: Attempts to load from nullptr in instanceKlass.cpp and unsafe.cpp
  • cb20a3e: 8319166: Typos in the JavaDocs for MemorySegment
  • 99efcde: 8317545: AIX PPC64: Implementation of Foreign Function & Memory API
  • e9d19d0: 8319300: Remove unused methods in WorkArounds and Utils
  • faa8bde: 8319206: [REDO] Event NativeLibraryLoad breaks invariant by taking a stacktrace when thread is in state _thread_in_native
  • 4f808c6: 8316538: runtime/handshake/MixedHandshakeWalkStackTest.java crashes with JFR
  • 2d4a4d0: 8315921: Invalid CSS declarations in java.lang class documentation
  • 792d829: 8319205: Parallel: Reenable work stealing after JDK-8310031
  • 23a96bf: 8318894: G1: Use uint for age in G1SurvRateGroup
  • ... and 7 more: https://git.openjdk.org/jdk/compare/f262f06c97b9ea94cd6119b3a8beb16bf804d083...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 openjdk bot added the ready Pull request is ready to be integrated label Nov 2, 2023
@mlchung
Copy link
Member Author

mlchung commented Nov 3, 2023

/integrate

@openjdk
Copy link

openjdk bot commented Nov 3, 2023

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

  • 1a21c1a: 8318736: com/sun/jdi/JdwpOnThrowTest.java failed with "transport error 202: bind failed: Address already in use"
  • 81db172: 8318955: Add ReleaseIntArrayElements in Java_sun_awt_X11_XlibWrapper_SetBitmapShape XlbWrapper.c to early return
  • be01caf: 8319323: FFM: Harmonize the @throws tags in the javadocs
  • ec79ab4: 8319268: Build failure with GCC8.3.1 after 8313643
  • c788160: 8296240: Augment discussion of test tiers in doc/testing.md
  • ffaecd4: 8315364: Assert thread state invariant for JFR stack trace capture
  • 3b65b87: 8316028: Update FreeType to 2.13.2
  • 9dc40ba: 8319195: Move most tier 1 vector API regression tests to tier 3
  • f875163: 8318982: Improve Exceptions::special_exception
  • 84f4f74: 8319213: Compatibility.java reads both stdout and stderr of JdkUtils
  • ... and 19 more: https://git.openjdk.org/jdk/compare/f262f06c97b9ea94cd6119b3a8beb16bf804d083...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Nov 3, 2023

@mlchung Pushed as commit 008ca2a.

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

@mlchung mlchung deleted the JDK-8317620 branch November 8, 2023 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build build-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants