-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
8264322: Generate CDS archive when creating custom JDK image #5174
Conversation
👋 Welcome back ccheung! A progress list of the required criteria for merging this PR into |
/label remove hotspot |
@calvinccheung The |
@calvinccheung |
@calvinccheung |
Webrevs
|
@@ -86,6 +86,7 @@ | |||
private final Path home; | |||
private final List<String> args; | |||
private final Set<String> modules; | |||
private Platform platform; |
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.
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.
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'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.
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.
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) { |
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.
This setter is not needed if it's passed to the constructor.
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.
Fixed.
* | ||
* @param p | ||
*/ | ||
public void setTargetPlatform(Platform p); |
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.
This method should not be needed. The platform should be known when an executable image is created.
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.
Fixed.
* | ||
* @return boolean | ||
*/ | ||
public boolean is64Bit(); |
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.
This is64Bit
method should belong to Platform
class
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. I've moved the method to the Platform
class.
/** | ||
* Gets the target image platform. | ||
* | ||
* @return Platform |
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.
* @return Platform | |
* @return {@code Platform} object representing the platform of the runtime image |
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.
Fixed.
generate-cds-archive.argument= | ||
|
||
generate-cds-archive.description=\ | ||
CDS plugin: generate cds archives (classes.jsa, classes_nocoops.jsa).\n\ |
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.
Is it necessary to show classes.jsa, classes_nocoops.jsa
the archive file name? Simply drop them?
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.
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. |
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.
\ 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?
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.
Yes.
ex.printStackTrace(); | ||
} | ||
if (status == 0) { | ||
System.out.println("Created " + archiveMsg + " archive successfully"); |
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.
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
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'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(); |
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.
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);
}
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'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=\ |
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.
This should not be needed. Leftover from an early version.
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.
Removed.
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 for the change. Looks okay.
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 for creating a JBS issue. I'm okay to follow up the test improvement as a separate issue.
@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:
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
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 |
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.
This looks okay, and I see a follow-on issue has been created for the test improvements.
@mlchung, @AlanBateman Thanks for the review and discussions. |
/integrate |
Going to push as commit f608e81.
Your commit was automatically rebased without conflicts. |
@calvinccheung Pushed as commit f608e81. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
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:
Progress
Issue
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