Skip to content

8343839: Detect patched modules and abort run-time image link early #22037

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

Closed
wants to merge 19 commits into from

Conversation

jerboaa
Copy link
Contributor

@jerboaa jerboaa commented Nov 12, 2024

Please review this fix to how patched modules are being handled when linking from the run-time image. During review of JDK-8311302 it was pointed out that module patching should be detected earlier and the link should get aborted in that case.

This patch implements it, by using ModuleBootstrap.patcher().hasPatches(). After this patch module patching is being detected before any archives are being read or the actual linking process starts (contrary to the previous solution).

Testing:

  • GHA testing (mac aarch64 test failures are infra related)
  • Local testing of existing test, which covers it

Thoughts?


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-8343839: Detect patched modules and abort run-time image link early (Bug - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 22037

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 12, 2024

👋 Welcome back sgehwolf! 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 12, 2024

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

8343839: Detect patched modules and abort run-time image link early

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

  • 9267dfa: 8344589: Update IANA Language Subtag Registry to Version 2024-11-19
  • 293323c: 8340141: C1: rework ciMethod::equals following 8338471
  • 76e874c: 8345319: Fix the tag type in PoolEntry and AnnotationValue
  • e9f6ba0: 8345293: Fix generational Shenandoah with compact headers
  • e1910f2: 8345397: Remove from g1HeapRegionRemSet.cpp
  • 3c60f0b: 8345296: AArch64: VM crashes with SIGILL when prctl is disallowed
  • 3eaa761: 8342086: FileInputStream.available() fails with "Incorrect function" for "nul" path (win)
  • 60bd73a: 8342089: Require --enable-native-access to be the same between CDS dump time and run time
  • 2be27e1: 8345393: ProblemList java/util/concurrent/locks/StampedLock/OOMEInStampedLock.java on generic-all JTREG_TEST_THREAD_FACTORY=Virtual
  • ba50939: 8341649: Regressions with large metaspace apps after 8338526
  • ... and 54 more: https://git.openjdk.org/jdk/compare/a80ccf2cd2792c24b51f1143cb0e6c5b036c5b28...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 rfr Pull request is ready for review label Nov 12, 2024
@openjdk
Copy link

openjdk bot commented Nov 12, 2024

@jerboaa 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 Nov 12, 2024
@jerboaa
Copy link
Contributor Author

jerboaa commented Nov 12, 2024

/label add jigsaw

@openjdk
Copy link

openjdk bot commented Nov 12, 2024

@jerboaa
The label jigsaw is not a valid label.
These labels are valid:

  • graal
  • serviceability
  • hotspot
  • hotspot-compiler
  • ide-support
  • kulla
  • i18n
  • shenandoah
  • jdk
  • javadoc
  • security
  • hotspot-runtime
  • jmx
  • build
  • nio
  • client
  • core-libs
  • compiler
  • net
  • hotspot-gc
  • hotspot-jfr

@mlbridge
Copy link

mlbridge bot commented Nov 12, 2024

Webrevs

@openjdk
Copy link

openjdk bot commented Nov 20, 2024

⚠️ @jerboaa This pull request contains merges that bring in commits not present in the target repository. Since this is not a "merge style" pull request, these changes will be squashed when this pull request in integrated. If this is your intention, then please ignore this message. If you want to preserve the commit structure, you must change the title of this pull request to Merge <project>:<branch> where <project> is the name of another project in the OpenJDK organization (for example Merge jdk:master).

@jerboaa jerboaa changed the base branch from master to pr/22277 November 20, 2024 16:51
@openjdk-notifier openjdk-notifier bot changed the base branch from pr/22277 to master November 27, 2024 19:55
@openjdk-notifier
Copy link

The parent pull request that this pull request depends on has been closed without being integrated and the target branch of this pull request has been updated as the previous branch was deleted. This means that changes from the parent pull request will start to show up in this pull request. If closing the parent pull request was done in error, it will need to be re-opened and this pull request will need to manually be retargeted again.

@jerboaa
Copy link
Contributor Author

jerboaa commented Nov 27, 2024

The latest version now uses the approach @mlchung suggested in #22277 (and doesn't depend on a public property any more). Please take another look.

The long-term plan would be to not need this at all. If we were to use the jrt FS throughout in JRTArchive I think module patches won't matter and wouldn't populate to the resulting image and this could get removed. But that would be for another enhancement. Thoughts?

@mlchung
Copy link
Member

mlchung commented Dec 2, 2024

The long-term plan would be to not need this at all. If we were to use the jrt FS throughout in JRTArchive I think module patches won't matter and wouldn't populate to the resulting image and this could get removed. But that would be for another enhancement. Thoughts?

IMO, I don't think it's worth putting the effort to support that as running jlink on a patched runtime should be very rare corner case.

@jerboaa
Copy link
Contributor Author

jerboaa commented Dec 3, 2024

The long-term plan would be to not need this at all. If we were to use the jrt FS throughout in JRTArchive I think module patches won't matter and wouldn't populate to the resulting image and this could get removed. But that would be for another enhancement. Thoughts?

IMO, I don't think it's worth putting the effort to support that as running jlink on a patched runtime should be very rare corner case.

Thanks for the feedback. I've filed https://bugs.openjdk.org/browse/JDK-8345184 anyway as it might allow us to remove some of the special cases.

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.

LGTM

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Dec 3, 2024
@jerboaa
Copy link
Contributor Author

jerboaa commented Dec 3, 2024

@AlanBateman OK with this too?

@jerboaa
Copy link
Contributor Author

jerboaa commented Dec 3, 2024

LGTM

Thanks for the review, @mlchung!

@AlanBateman
Copy link
Contributor

@AlanBateman OK with this too?

ModuleBootstap is the place to initialize the module system and setup the boot layer. The ModuleBootstrap.patcher() method is there for its buddy SystemModuleFinders, it should not be public. So I suppose what you have is okay but I think we're going to have work on removing this coupling in the future.

@jerboaa
Copy link
Contributor Author

jerboaa commented Dec 3, 2024

@AlanBateman OK with this too?

ModuleBootstap is the place to initialize the module system and setup the boot layer. The ModuleBootstrap.patcher() method is there for its buddy SystemModuleFinders, it should not be public. So I suppose what you have is okay but I think we're going to have work on removing this coupling in the future.

https://bugs.openjdk.org/browse/JDK-8345184 might solve this. If we don't need to special case a patched runtime this all goes away.

@jerboaa
Copy link
Contributor Author

jerboaa commented Dec 3, 2024

I'll integrate this and have a look at JDK-8345184 as a follow up.

@jerboaa
Copy link
Contributor Author

jerboaa commented Dec 3, 2024

/integrate

@openjdk
Copy link

openjdk bot commented Dec 3, 2024

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

  • 0664b51: 8344987: Test serviceability/sa/TestJhsdbJstackPrintVMLocks.java fails: NoClassDefFoundError: jdk/test/lib/Utils
  • 157a434: 8345389: Bump missed copyright years for JDK-8336768
  • a49f077: 8345221: Replace legacy with new Provider APIs in SunNativeGSS
  • 2be07b5: 8324491: Keyboard layout didn't keep its state if it was changed when dialog was active
  • f37f64d: 8343736: Test java/awt/Focus/UnaccessibleChoice/AccessibleChoiceTest.java failed: Choice can't be controlled by keyboard
  • 73b8b34: 8344368: IndependenceSwingTest.java and IndependenceAWTTest.java failed: Selected text & clipboard contents differs
  • 9267dfa: 8344589: Update IANA Language Subtag Registry to Version 2024-11-19
  • 293323c: 8340141: C1: rework ciMethod::equals following 8338471
  • 76e874c: 8345319: Fix the tag type in PoolEntry and AnnotationValue
  • e9f6ba0: 8345293: Fix generational Shenandoah with compact headers
  • ... and 60 more: https://git.openjdk.org/jdk/compare/a80ccf2cd2792c24b51f1143cb0e6c5b036c5b28...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Dec 3, 2024

@jerboaa Pushed as commit 05ee562.

💡 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
core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants