Skip to content

Conversation

@dougxc
Copy link
Member

@dougxc dougxc commented Sep 27, 2022

This PR adds a new jlink plugin (--save-jlink-argfiles=<filenames>) to support persisting jlink options.

> echo "--add-modules jdk.internal.vm.ci --add-options=-Dfoo=xyzzy --vendor-version=\"XyzzyVM 3.14.15\" --vendor-bug-url=https://bugs.xyzzy.com/" > my_image.argfile
> export ALL_MODULES=$(java --list-modules | sed 's:@.*::g' | tr '\n' ',')
> jlink --keep-packaged-modules=my_image/jmods --add-modules $ALL_MODULES --output=my_image --save-jlink-argfiles my_image.argfile
> my_image/bin/java -XshowSettings:properties --version 2>&1 | grep yzzy
> my_image/bin/jlink --add-modules=java.base --output=my_image2
> my_image2/bin/java -XshowSettings:properties --version 2>&1 | grep yzzy
    foo = xyzzy
    java.vendor.url.bug = https://bugs.xyzzy.com/
    java.vendor.version = XyzzyVM 3.14.15
OpenJDK Runtime Environment XyzzyVM 3.14.15 (build 20-internal-2022-09-22-0951036.dnsimon...)
OpenJDK 64-Bit Server VM XyzzyVM 3.14.15 (build 20-internal-2022-09-22-0951036.dnsimon..., mixed mode)
> my_image2/bin/java -d jdk.internal.vm.ci | head -1
jdk.internal.vm.ci@20-internal

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 a CSR request to be approved

Issues

  • JDK-8237467: jlink plugin to save the argument files as input to jlink in the output image
  • JDK-8294485: jlink plugin to save the argument files as input to jlink in the output image (CSR)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 10445

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 27, 2022

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

@dougxc
Copy link
Member Author

dougxc commented Sep 27, 2022

/reviewer @mlchung

@openjdk
Copy link

openjdk bot commented Sep 27, 2022

@dougxc Syntax: /reviewer (credit|remove) [@user | openjdk-user]+. For example:

  • /reviewer credit @openjdk-bot
  • /reviewer credit duke
  • /reviewer credit @user1 @user2

@openjdk
Copy link

openjdk bot commented Sep 27, 2022

@dougxc The following label will be automatically applied to this pull request:

  • core-libs

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

@openjdk openjdk bot added the core-libs core-libs-dev@openjdk.org label Sep 27, 2022
@dougxc dougxc force-pushed the JDK-8237467/SaveJlinkArgfilesPlugin branch from 0b1cecb to 583981a Compare September 27, 2022 11:33
@openjdk openjdk bot added the rfr Pull request is ready for review label Sep 27, 2022
@mlbridge
Copy link

mlbridge bot commented Sep 27, 2022

Webrevs

@@ -0,0 +1,171 @@
/*
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

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

This is a new file and so I would just have the copyright start year.

/**
* Various utility methods for processing Java tool command line arguments.
*
* <p><b>This is NOT part of any supported API.
Copy link
Member

Choose a reason for hiding this comment

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

This note was prior to module system. We could drop this comment since it's encapsulated and it's not an exported package.

}
Path outputPath = null;
try {
try (InputStream savedOptions = JlinkTask.class.getModule().getResourceAsStream("jdk/tools/jlink/internal/options")) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: wrap this long line that helps future side-by-side review.

Copy link
Member

Choose a reason for hiding this comment

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

Nit: define a static variable for this resource file name jdk/tools/jlink/internal/options that the plugin can use.

try {
try (InputStream savedOptions = JlinkTask.class.getModule().getResourceAsStream("jdk/tools/jlink/internal/options")) {
if (savedOptions != null) {
List<String> newArgs = new ArrayList<>();
Copy link
Member

Choose a reason for hiding this comment

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

s/newArgs/prependArgs/ to make it clearer.

@Override
public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {
in.transformAndCopy(Function.identity(), out);
byte[] savedOptions = argfiles.stream().
Copy link
Member

Choose a reason for hiding this comment

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

Formatting consistent with jlink files:

Suggested change
byte[] savedOptions = argfiles.stream().
byte[] savedOptions = argfiles.stream()
.collect(Collectors.joining("\n"))
.getBytes(StandardCharsets.UTF_8);


// Check that the primary image creation ignored the saved args
oa.shouldHaveExitValue(0);
oa.shouldNotMatch("yzzy");
Copy link
Member

Choose a reason for hiding this comment

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

Can this check for java.vendor.version = XyzzyVM 3.14.15, that will also help the reader to understand what the test tries to verify.

launcher = image2.resolve(Path.of("bin", "java" + exe));
oa = ProcessTools.executeProcess(launcher.toString(), "-XshowSettings:properties", "--version");
oa.shouldHaveExitValue(0);
expectNMatchingLines(oa.getStdout(), "yzzy", 2);
Copy link
Member

Choose a reason for hiding this comment

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

Same for line 94-95: check for java.vendor.version = XyzzyVM 3.14.15 instead

@mlchung
Copy link
Member

mlchung commented Sep 27, 2022

/csr

@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label Sep 27, 2022
@openjdk
Copy link

openjdk bot commented Sep 27, 2022

@mlchung has indicated that a compatibility and specification (CSR) request is needed for this pull request.

@dougxc please create a CSR request for issue JDK-8237467 with the correct fix version. This pull request cannot be integrated until the CSR request is approved.

@openjdk-notifier
Copy link

@dougxc Please do not rebase or force-push to an active PR as it invalidates existing review comments. All changes will be squashed into a single commit automatically when integrating. See OpenJDK Developers’ Guide for more information.

@dougxc dougxc changed the title 8237467: effect of jlink plugins for vendor information and command-line options should be sticky 8237467: jlink plugin to save the argument files to jlink in the output image Sep 27, 2022
@dougxc dougxc changed the title 8237467: jlink plugin to save the argument files to jlink in the output image 8237467: jlink plugin to save the argument files as input to jlink in the output image Sep 27, 2022
throw new AssertionError();

for (String argfile : v.split(File.pathSeparator)) {
argfiles.add(readArgfile(argfile));
Copy link
Member

@mlchung mlchung Sep 27, 2022

Choose a reason for hiding this comment

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

This plugin should validate if jdk.jlink is linked in the resulting image; if not, it should throw an exception.

Otherwise, looks good.

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.

Looks good.

@openjdk openjdk bot removed the csr Pull request needs approved CSR before integration label Oct 2, 2022
@openjdk
Copy link

openjdk bot commented Oct 2, 2022

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

8237467: jlink plugin to save the argument files as input to jlink in the output image

Reviewed-by: mchung

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

  • b8b9b97: 8294676: [JVMCI] InstalledCode.deoptimize(false) should not touch address field
  • fd59430: 8294610: java/net/vthread/HttpALot.java is slow on Linux
  • c7ab1ca: 8294609: C2: Improve inlining of methods with unloaded signature classes
  • 375f02f: 8294608: Remove redundant unchecked suppression in FileDescriptor
  • d207da8: 8294533: Documentation mistake in Process::getErrorStream and getInputStream
  • da4e96d: 8276545: Fix handling of trap count overflow in Parse::Parse()
  • 48674d4: 8291428: JFR: 'jfr print' displays incorrect timestamps during DST
  • 3b1bc21: 8294307: ISO 4217 Amendment 173 Update
  • b8f9a91: 8293940: Some tests for virtual threads take too long
  • 1d26c4b: 8291022: JFR: Reduce logging in ChunkHeader constructor
  • ... and 58 more: https://git.openjdk.org/jdk/compare/dd51f7e0b75d3a16403608d89cd206ac0bedf882...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 Oct 2, 2022
@dougxc
Copy link
Member Author

dougxc commented Oct 3, 2022

/integrate

@dougxc
Copy link
Member Author

dougxc commented Oct 3, 2022

Thanks for the reviews @mlchung !

@openjdk
Copy link

openjdk bot commented Oct 3, 2022

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

  • edfb18a: 8294695: Remove redundant deprecation suppression in ThreadGroup
  • 46633e6: 8294698: Remove unused 'checkedExceptions' param from MethodAccessorGenerator.generateMethod()
  • f2a32d9: 8293691: converting a defined BasicType value to a string should not crash the VM
  • ccc1d31: 8294529: IGV: Highlight the current graphs in the Outline
  • 08a7ecf: 8294671: Remove unused CardValues::last_card
  • 5fe837a: 8294236: [IR Framework] CPU preconditions are overriden by regular preconditions
  • 8e9cfeb: 8294431: jshell reports error on initialisation of static final field of anonymous class
  • 6e8f038: 8294567: IGV: IllegalStateException in search
  • bc668b9: 8293099: JFR: Typo in TestRemoteDump.java
  • 03f25a9: 8293562: blocked threads with KeepAliveCache.get
  • ... and 69 more: https://git.openjdk.org/jdk/compare/dd51f7e0b75d3a16403608d89cd206ac0bedf882...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Oct 3, 2022

@dougxc Pushed as commit 4f44fd6.

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

@dougxc dougxc deleted the JDK-8237467/SaveJlinkArgfilesPlugin branch May 23, 2023 07:51
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 integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

2 participants