- Notifications
You must be signed in to change notification settings - Fork 6.1k
8363980: [macos] Add JDK specific keys/values to Info.plist of embedded runtime #28033
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
base: master
Are you sure you want to change the base?
Conversation
| 👋 Welcome back almatvee! A progress list of the required criteria for merging this PR into |
| ❗ This change is not yet ready to be integrated. |
| @sashamatveev The following label will be automatically applied to this pull request:
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. |
| @alexeysemenyukoracle Please review. |
| | ||
| final var app = env.app(); | ||
| | ||
| // We should use full runtime info plist for standalone runtime and for |
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 guess the comment explains why jpackage should use the same info plist template for a runtime if it has the "bin" subdirectory. But what is the "full" runtime?
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.
"full" runtime info plist -> refers to info plist from standalone runtime. I will re-write it to:
// We should use info plist from standalone runtime for embedded runtime // if embedded runtime contains "bin" folder, so embedded runtime // can act as standalone runtime. Standalone runtime always uses same // info plist which has "JavaVM" dictionary. 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.
so embedded runtime can act as standalone runtime
This can imply many things. I suggest more specific wording:
If the embedded runtime contains executable(s) in the "bin" subdirectory, we should use the standalone runtime info plist template. Otherwise, the user may be unable to run the "java" or other executables in the "bin" subdirectory of the embedded runtime.
| How do we test the defaults? We need a new test that will verify that if the runtime has a "bin" subdirectory, the runtime plist file has "standalone runtime"-specific properties and vice versa.
|
| // Need to make the code in rpm spec happy as it assumes there is | ||
| // always something in application image. | ||
| fakeRuntimeDir.resolve("bin").toFile().mkdir(); | ||
| createBulkFile.accept(fakeRuntimeDir.resolve(Path.of("bin", "bulk"))); |
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 change makes the above fakeRuntimeDir.resolve("bin").toFile().mkdir(); redundant. Overall, the whole
if (TKit.isLinux()) { // Need to make the code in rpm spec happy as it assumes there is // always something in application image. fakeRuntimeDir.resolve("bin").toFile().mkdir(); } construction is redundant and can be replaced with:
if (includeBin) { createBulkFile.accept(fakeRuntimeDir.resolve(Path.of("bin", "bulk"))); } 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.
We still need to add file to "bin" for Linux. I will change it to:
// Need to make the code in rpm spec happy as it assumes there is // always something in application image. includeBin |= TKit.isLinux(); if (includeBin) { createBulkFile.accept(fakeRuntimeDir.resolve(Path.of("bin", "bulk"))); } 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.
We still need to add file to "bin" for Linux. I will change it to:
I simplified the body of the setFakeRuntime() function as follows:
addPrerequisiteAction(cmd -> { Path fakeRuntimeDir = TKit.createTempDirectory("fake_runtime"); TKit.trace(String.format("Init fake runtime in [%s] directory", fakeRuntimeDir)); if (TKit.isOSX()) { // Make MacAppImageBuilder happy createBulkFile.accept(fakeRuntimeDir.resolve(Path.of( "lib/jli/libjli.dylib"))); } // Make sure fake runtime takes some disk space. // Package bundles with 0KB size are unexpected and considered // an error by PackageTest. createBulkFile.accept(fakeRuntimeDir.resolve(Path.of("lib", "bulk"))); cmd.setArgumentValue("--runtime-image", fakeRuntimeDir); }); And ran Windows and Linux tests that use it. All passed.
WinOSConditionTest:
[18:44:19.893] TRACE: assertStringListEquals(): Check jpackage didn't modify ${RUNTIME_IMAGE}=[C:\jpackage-tests\WinOSConditionTest\test\fake_runtime-0] [18:44:19.893] TRACE: assertStringListEquals(1, #) [18:44:19.894] TRACE: assertStringListEquals(2, lib#) [18:44:19.894] TRACE: assertStringListEquals(3, lib\bulk#2025-10-30T22:44:17.6191874Z) [18:44:19.894] TRACE: assertTrue(): Check [WinOSConditionTest\test\output\WinOSConditionTest-1.0.msi] path exists AppAboutUrlTest.testDefaults (DEB):
[18:49:22.115] TRACE: assertStringListEquals(): Check jpackage didn't modify ${RUNTIME_IMAGE}=[/jpackage-tests/AppAboutUrlTest/testDefaults/fake_runtime] [18:49:22.120] TRACE: assertStringListEquals(1, #) [18:49:22.120] TRACE: assertStringListEquals(2, lib#) [18:49:22.120] TRACE: assertStringListEquals(3, lib/bulk#2025-10-30T22:49:20.128409727Z) [18:49:22.120] TRACE: assertTrue(): Check [AppAboutUrlTest/testDefaults/output/defaultsappabouturltest_1.0_amd64.deb] path exists AppAboutUrlTest.testDefaults (RPM):
[18:56:37.897] TRACE: assertStringListEquals(): Check jpackage didn't modify ${RUNTIME_IMAGE}=[/jpackage-tests/AppAboutUrlTest/testDefaults/fake_runtime] [18:56:37.898] TRACE: assertStringListEquals(1, #) [18:56:37.898] TRACE: assertStringListEquals(2, lib#) [18:56:37.898] TRACE: assertStringListEquals(3, lib/bulk#2025-10-30T22:56:37.204554597Z) [18:56:37.898] TRACE: assertTrue(): Check [AppAboutUrlTest/testDefaults/output/defaultsappabouturltest-1.0-1.x86_64.rpm] path exists 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.
The diff:
diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java index fcd940e725e..73af859b6ac 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java @@ -307,24 +307,16 @@ public JPackageCommand setFakeRuntime() { TKit.trace(String.format("Init fake runtime in [%s] directory", fakeRuntimeDir)); - Files.createDirectories(fakeRuntimeDir); - - if (TKit.isLinux()) { - // Need to make the code in rpm spec happy as it assumes there is - // always something in application image. - fakeRuntimeDir.resolve("bin").toFile().mkdir(); - } - if (TKit.isOSX()) { // Make MacAppImageBuilder happy createBulkFile.accept(fakeRuntimeDir.resolve(Path.of( "lib/jli/libjli.dylib"))); } - // Mak sure fake runtime takes some disk space. + // Make sure fake runtime takes some disk space. // Package bundles with 0KB size are unexpected and considered // an error by PackageTest. - createBulkFile.accept(fakeRuntimeDir.resolve(Path.of("bin", "bulk"))); + createBulkFile.accept(fakeRuntimeDir.resolve(Path.of("lib", "bulk"))); cmd.setArgumentValue("--runtime-image", fakeRuntimeDir); });
Why? jpackage picks the same file from the resource directory regardless of whether the "bin" subdirectory is present in the runtime. The "bin" subdirectory in the runtime only affects the default plist resource that jpackage uses. |
| final var useRuntimeInfoPlist = | ||
| Files.isDirectory(env.resolvedLayout().runtimeDirectory().resolve("bin")) || | ||
| app.isRuntime(); | ||
| |
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.
The writeRuntimeInfoPlist() action is executed for the MacBuildApplicationTaskID.RUNTIME_INFO_PLIST and MacBuildApplicationTaskID.COPY_RUNTIME_INFO_PLIST tasks. MacBuildApplicationTaskID.RUNTIME_INFO_PLIST doesn't have dependencies. This means it can be executed before the runtime files are available in the output app image. Currently, this is not a problem because jpackage executes tasks synchronously, but eventually it will run them asynchronously, and the Files.isDirectory(...) test will fail.
The plist template should be selected at the configuration phase, not the bundling phase. However, this will require knowing/guessing if jlink will create native commands in the "bin" directory from its command line. It is straightforward if it boils down to testing whether it has the "--strip-native-commands" option. This is what we do when we test if jlink options are correct for the Apple App Store, right? Test for "--strip-native-commands" in DeployParams.java
I'd suggest adding boolean jdk.jpackage.internal.model.RuntimeBuilder.withNativeCommands() method. Then the code will be:
final var useRuntimeInfoPlist = app.isRuntime() || app.runtimeBuilder().orElseThrow().withNativeCommands(); Alternatively, you may add the BuildApplicationTaskID.RUNTIME task as a dependency for the MacBuildApplicationTaskID.RUNTIME_INFO_PLIST task. However, this is a less preferable solution.
Not sure. I agree we should not mix testing this fix with |
setFakeRuntime()not to includebinfolder. By default it was always included, but generated embedded runtime by default does not havebinfolder. As a resultCustomInfoPListTestfailed.CustomInfoPListTestto test Info.plist withbinfolder.Progress
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/28033/head:pull/28033$ git checkout pull/28033Update a local copy of the PR:
$ git checkout pull/28033$ git pull https://git.openjdk.org/jdk.git pull/28033/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 28033View PR using the GUI difftool:
$ git pr show -t 28033Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/28033.diff
Using Webrev
Link to Webrev Comment