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

8264322: Generate CDS archive when creating custom JDK image #5174

Closed

Conversation

calvinccheung
Copy link
Member

@calvinccheung calvinccheung commented Aug 18, 2021

Please review this change for adding a jlink command line option --generate-cds-archive for generating CDS archives as a post processing step during the creation of a custom JDK image.

Details can be found in the corresponding CSR JDK-8269178.

Testing:

  • tiers 1,2 (including the new test)

Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8264322: Generate CDS archive when creating custom JDK image

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5174/head:pull/5174
$ git checkout pull/5174

Update a local copy of the PR:
$ git checkout pull/5174
$ git pull https://git.openjdk.java.net/jdk pull/5174/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 5174

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5174.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 18, 2021

👋 Welcome back ccheung! 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.

@calvinccheung
Copy link
Member Author

/label remove hotspot
/label add core-libs
/label add hotspot-runtime

@openjdk
Copy link

openjdk bot commented Aug 18, 2021

@calvinccheung The hotspot label was not set.

@openjdk openjdk bot added the core-libs core-libs-dev@openjdk.org label Aug 18, 2021
@openjdk
Copy link

openjdk bot commented Aug 18, 2021

@calvinccheung
The core-libs label was successfully added.

@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Aug 18, 2021
@openjdk
Copy link

openjdk bot commented Aug 18, 2021

@calvinccheung
The hotspot-runtime label was successfully added.

@calvinccheung calvinccheung marked this pull request as ready for review August 18, 2021 21:27
@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 18, 2021
@mlbridge
Copy link

mlbridge bot commented Aug 18, 2021

Webrevs

@@ -86,6 +86,7 @@
private final Path home;
private final List<String> args;
private final Set<String> modules;
private Platform platform;
Copy link
Member

Choose a reason for hiding this comment

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

Can DefaultExecutableImage constructor take an additional platform argument and make this platform field final?

When the DefaultExecutableImage is constructed, it already has the target platform information.

In the constructor, it can check if the platform parameter must not be UNKNOWN; otherwise throw IAE.

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've added the platform argument and made the platform field final.
However, as we've discussed offline, there's a code path via the --post-process-path option where the platform may not be available. So we can't throw IAE on an UNKNOWN platform in the constructor.

Copy link
Member

Choose a reason for hiding this comment

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

Since --post-process-path is a hidden option, it's fine not to support it.

@@ -127,13 +129,29 @@ public void storeLaunchArgs(List<String> args) {
throw new UncheckedIOException(ex);
}
}

@Override
public void setTargetPlatform(Platform p) {
Copy link
Member

Choose a reason for hiding this comment

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

This setter is not needed if it's passed to the constructor.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

*
* @param p
*/
public void setTargetPlatform(Platform p);
Copy link
Member

Choose a reason for hiding this comment

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

This method should not be needed. The platform should be known when an executable image is created.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

*
* @return boolean
*/
public boolean is64Bit();
Copy link
Member

Choose a reason for hiding this comment

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

This is64Bit method should belong to Platform class

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. I've moved the method to the Platform class.

/**
* Gets the target image platform.
*
* @return Platform
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
* @return Platform
* @return {@code Platform} object representing the platform of the runtime image

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

generate-cds-archive.argument=

generate-cds-archive.description=\
CDS plugin: generate cds archives (classes.jsa, classes_nocoops.jsa).\n\
Copy link
Member

Choose a reason for hiding this comment

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

Is it necessary to show classes.jsa, classes_nocoops.jsa the archive file name? Simply drop them?

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed the file names.


generate-cds-archive.usage=\
\ --generate-cds-archive Generate CDS archives (classes.jsa, classes_nocoops.jsa).\n\
\ Applicable to JDK images built with the CDS feature.
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
\ Applicable to JDK images built with the CDS feature.
\ --generate-cds-archive Generate CDS archives if the runtime image supports CDS feature.\n\

Does this match what you want to say?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes.

ex.printStackTrace();
}
if (status == 0) {
System.out.println("Created " + archiveMsg + " archive successfully");
Copy link
Member

Choose a reason for hiding this comment

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

Is it significant to print two lines on 64-bit platform? Users may not have any idea what NOCOOPS means?

Created CDS archive successfully
Created NOCOOPS CDS archive successfully

It seems adequate to me as a user to get one output:

Created CDS archive successfully

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've made the change; the plugin will print only one successful message.

Process p = builder.inheritIO().start();
status = p.waitFor();
} catch (Exception ex) {
ex.printStackTrace();
Copy link
Member

Choose a reason for hiding this comment

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

This plugin should fail with any exception. jlink will handle PluginException and UncheckedIOException and print the error message. You can simply wrap IOException with UncheckedIOException

 try {
       Process p = builder.inheritIO().start();
       status = p.waitFor();
 } catch (IOException e) {
       throw new UncheckedIOException(e);
 }           

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've changed it to the following since we also need to catch the InterruptedException:

try {
            Process p = builder.inheritIO().start();
            status = p.waitFor();
        } catch (InterruptedException | IOException e) {
            throw new PluginException(e);
        }

@@ -87,6 +87,9 @@ main.opt.ignore-signing-information=\
\ signed modular JARs are not copied to\n\
\ the runtime image.

main.opt.generate-cds-archive=\
Copy link
Member

Choose a reason for hiding this comment

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

This should not be needed. Leftover from an early version.

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed.

Copy link
Member

@mlchung mlchung left a comment

Choose a reason for hiding this comment

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

Thanks for the change. Looks okay.

Copy link
Member

@mlchung mlchung left a comment

Choose a reason for hiding this comment

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

Thanks for creating a JBS issue. I'm okay to follow up the test improvement as a separate issue.

@openjdk
Copy link

openjdk bot commented Aug 24, 2021

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

8264322: Generate CDS archive when creating custom JDK image

Reviewed-by: mchung, 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 37 new commits pushed to the master branch:

  • 7f80683: 8272783: Epsilon: Refactor tests to improve performance
  • 22ef4f0: 5015261: NPE may be thrown if JDesktopIcon is set to null on a JInternalFrame
  • 9bc0232: 8269223: -Xcheck:jni WARNINGs working with fonts on Linux
  • 2ff4c01: 8271600: C2: CheckCastPP which should closely follow Allocate is sunk of a loop
  • ad92033: 8272736: [JVMCI] Add API for reading and writing JVMCI thread locals
  • 709b591: 8272553: several hotspot runtime/CommandLine tests don't check exit code
  • 1884072: 8265253: javac -Xdoclint:all gives "no comment" warning for code that can't be commented
  • 594e516: 8272778: Consolidate is_instance and is_instance_inlined in java_lang_String
  • d542745: 8267894: Skip work for empty regions in G1 Full GC
  • 741f58c: 8272417: ZGC: fastdebug build crashes when printing ClassLoaderData
  • ... and 27 more: https://git.openjdk.java.net/jdk/compare/73da66ffb707abf6dc38368a12e337d52597de25...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 Aug 24, 2021
Copy link
Contributor

@AlanBateman AlanBateman left a comment

Choose a reason for hiding this comment

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

This looks okay, and I see a follow-on issue has been created for the test improvements.

@calvinccheung
Copy link
Member Author

@mlchung, @AlanBateman Thanks for the review and discussions.

@calvinccheung
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Aug 24, 2021

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

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Aug 24, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Aug 24, 2021
@openjdk
Copy link

openjdk bot commented Aug 24, 2021

@calvinccheung Pushed as commit f608e81.

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

@calvinccheung calvinccheung deleted the 8264322-jlink-cds-archive branch August 24, 2021 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs core-libs-dev@openjdk.org hotspot-runtime hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants