Skip to content

8347831: Re-examine version check when cross linking#28155

Closed
slowhog wants to merge 10 commits intoopenjdk:masterfrom
slowhog:JDK-8347831
Closed

8347831: Re-examine version check when cross linking#28155
slowhog wants to merge 10 commits intoopenjdk:masterfrom
slowhog:JDK-8347831

Conversation

@slowhog
Copy link
Contributor

@slowhog slowhog commented Nov 5, 2025

This PR include build changes from @magicus and jlink change to verify the build signature.

Tested with local builds for MacOS and Linux as below shows that cross linking with same build is working while linking with different build failed with error message.

❯ export JAVA_HOME=./build/macosx-x86_64-server-fastdebug/images/jdk-bundle/jdk-26.jdk/Contents/Home

❯ java --version
openjdk 26-internal 2026-03-17
OpenJDK Runtime Environment (fastdebug build 26-internal-adhoc.hjen.JDK-8347831)
OpenJDK 64-Bit Server VM (fastdebug build 26-internal-adhoc.hjen.JDK-8347831, mixed mode, sharing)

❯ jlink --version
26-internal

❯ jlink --module-path ./build/linux-x86_64-server-release/images/jdk/jmods --add-modules java.base --output linux

❯ jlink --add-modules java.base --output macos

❯ jlink --module-path ~/linux/jdk-25.0.1/jmods --add-modules java.base --output linux25
Error: jlink build N/A-26-internal-adhoc.hjen.JDK-8347831-2026-03-17 does not match target java.base build N/A

❯ jlink --module-path /Library/Java/JavaVirtualMachines/jdk-25.jdk/Contents/Home/jmods --add-modules java.base --output macos25
Error: jlink build N/A-26-internal-adhoc.hjen.JDK-8347831-2026-03-17 does not match target java.base build N/A


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

Issues

  • JDK-8347831: Re-examine version check when cross linking (Enhancement - P3)
  • JDK-8371575: Re-examine version check when cross linking (CSR)

Reviewers

Contributors

  • Magnus Ihse Bursie <ihse@openjdk.org>

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 28155

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 5, 2025

👋 Welcome back henryjen! 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
Copy link

openjdk bot commented Nov 5, 2025

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

8347831: Re-examine version check when cross linking

Co-authored-by: Magnus Ihse Bursie <ihse@openjdk.org>
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 5 new commits pushed to the master branch:

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 build build-dev@openjdk.org core-libs core-libs-dev@openjdk.org labels Nov 5, 2025
@openjdk
Copy link

openjdk bot commented Nov 5, 2025

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

  • build
  • core-libs

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 the rfr Pull request is ready for review label Nov 5, 2025
@mlbridge
Copy link

mlbridge bot commented Nov 5, 2025

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.

I'm not thrilled about the code duplication between Gensrc.gmk in java.base and and jdk.jlink. I think this should be extracted out into a common file in some way. Having 2 copies of the template file also seems suboptimal.

@AlanBateman
Copy link
Contributor

AlanBateman commented Nov 6, 2025

I'm puzzled as to why the resource has to be saved in the jdk.jlink module. When cross linking, jlink should only need to check the company/version of java.base in the current image vs. company/version of the java.base found on the module path.

@AlanBateman
Copy link
Contributor

This PR include build changes from @magicus and jlink change to verify the build signature.

In that case, you'll need to list Magnus (/contributor command).

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.

The updated version is much simpler, thank you. Just a few small comments on the jlink changes.

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.

Build changes look good now, pending Alan's comment about location of the output file.

@slowhog
Copy link
Contributor Author

slowhog commented Nov 7, 2025

/contributor @magicus

@openjdk
Copy link

openjdk bot commented Nov 7, 2025

@slowhog Syntax: /contributor (add|remove) [@user | openjdk-user | Full Name <email@address>]. For example:

  • /contributor add @openjdk-bot
  • /contributor add duke
  • /contributor add J. Duke <duke@openjdk.org>

User names can only be used for users in the census associated with this repository. For other contributors you need to supply the full name and email address.

@slowhog
Copy link
Contributor Author

slowhog commented Nov 7, 2025

/contributor add @magicus

@openjdk
Copy link

openjdk bot commented Nov 7, 2025

@slowhog
Contributor Magnus Ihse Bursie <ihse@openjdk.org> successfully added.

@AlanBateman
Copy link
Contributor

/csr

@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label Nov 8, 2025
@openjdk
Copy link

openjdk bot commented Nov 8, 2025

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

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

Copy link
Contributor

@jerboaa jerboaa left a comment

Choose a reason for hiding this comment

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

I think this can be tested akin to JLinkOptionsTest by implementing a simple plugin that transforms the release.txt resource and uses --keep-packaged-modules and then attempts to perform a link on the resulting image. Similarly we could cover the case of release.txt missing by using the --exclude-resources plugin.

}

try (var r = new BufferedReader(new InputStreamReader(release.get()))) {
return Optional.of(r.readLine());
Copy link
Contributor

Choose a reason for hiding this comment

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

As suggested on the CSR we should read the entire file, not just the first line and treat the entire content as a string in a specific encoding. While I wasn't able to get the JDK build a vendor name with new lines (due to jrt-fs.jar putting COMPANYNAME in the MANIFEST.MF) it's conceivable that some release.txt file might have more than one line.

Alternatively we need to specify that the file must not contain line breaks or unusual encodings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The proposal is to have a one line release signature set up by the build, briefly discussed the possibility to use a java properties file format as the current release file distributed with JDK, but then a simplified approach of one signature is preferred.

I'll update the PR once we come to conclusion with the CSR.

Copy link
Contributor

Choose a reason for hiding this comment

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

It might be useful to see what breaks if a JDK were built with a newline in the vendor name, I assume other things will break.

Overall I think the changes are looking good, the main thing is that the error message is clear.

Copy link
Contributor

Choose a reason for hiding this comment

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

It might be useful to see what breaks if a JDK were built with a newline in the vendor name, I assume other things will break.

Writhing the manifest entries for jrt-fs.jar break (header validation fails). Since the vendor populates to that jar file.

Copy link
Contributor Author

@slowhog slowhog Dec 2, 2025

Choose a reason for hiding this comment

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

The CSR is approved, and the one line signature is in the text.
And since other things break with newline in the vendor name, I assume that vendor name is also limited, so are we good with current implementation?
Are we suggesting to add error message when there is more than one line? I think current implementation is fine.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need to be concerned with this right now.

@openjdk openjdk bot removed the csr Pull request needs approved CSR before integration label Dec 2, 2025
@AlanBateman
Copy link
Contributor

I think this can be tested akin to JLinkOptionsTest by implementing a simple plugin that transforms the release.txt resource and uses --keep-packaged-modules and then attempts to perform a link on the resulting image. Similarly we could cover the case of release.txt missing by using the --exclude-resources plugin.

Maybe we should have a follow-up issue to attempt to create a test for this. However, the bigger topic of testing the cross-linking scenario isn't really something we can do in a jtreg test. Instead it is something for "special testing", like the manual tests, as it needs builds from different platforms.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Dec 2, 2025
@jerboaa
Copy link
Contributor

jerboaa commented Dec 2, 2025

I think this can be tested akin to JLinkOptionsTest by implementing a simple plugin that transforms the release.txt resource and uses --keep-packaged-modules and then attempts to perform a link on the resulting image. Similarly we could cover the case of release.txt missing by using the --exclude-resources plugin.

Maybe we should have a follow-up issue to attempt to create a test for this.

That's OK with me. Creating jtreg tests verifying that it fails if the file doesn't match/does not exist can still be done.

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.

Build change looks ok.

@slowhog
Copy link
Contributor Author

slowhog commented Dec 2, 2025

/integrate

@openjdk
Copy link

openjdk bot commented Dec 2, 2025

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

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Dec 2, 2025

@slowhog Pushed as commit 8f0cb57.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build build-dev@openjdk.org core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

5 participants