Skip to content

Conversation

@alexeysemenyukoracle
Copy link
Member

@alexeysemenyukoracle alexeysemenyukoracle commented Oct 22, 2025

Don't put the default icon (.png) files in the app image on Linux.

A simple fix would be to add a condition to LinuxPackagingPipeline.writeLauncherIcons() without changing interfaces in the model. However, this would leave unaddressed a long-standing issue with ApplicationImageUtils.createLauncherIconResource() function that requires the main launcher to calculate an icon resource for an additional launcher. At the packaging phase, any Launcher instance should be self-sufficient. Fixing ApplicationImageUtils.createLauncherIconResource() required adding a new interface ResourceDirLauncherIcon to the model and changing the semantics of the DefaultLauncherIcon interface.

A new ApplicationBuilder.normalizeLauncherProperty() function has been added to calculate the value of an additional launcher's property from the value of this property in the main launcher. The function is supposed to calculate a description, shortcuts, an icon, and any future launcher property. For now, it is used to calculate the launcher icon.


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-8370100: Redundant .png files in Linux app-image cause unnecessary bloat (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 27928

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 22, 2025

👋 Welcome back asemenyuk! 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 Oct 22, 2025

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

8370100: Redundant .png files in Linux app-image cause unnecessary bloat

Reviewed-by: almatvee

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 33 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 the core-libs core-libs-dev@openjdk.org label Oct 22, 2025
@openjdk
Copy link

openjdk bot commented Oct 22, 2025

@alexeysemenyukoracle 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
Copy link

openjdk bot commented Oct 23, 2025

@alexeysemenyukoracle this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout JDK-8370100
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label Oct 23, 2025
@openjdk openjdk bot removed the merge-conflict Pull request has merge conflict with target branch label Oct 23, 2025
@alexeysemenyukoracle alexeysemenyukoracle marked this pull request as ready for review October 24, 2025 04:36
@alexeysemenyukoracle
Copy link
Member Author

@sashamatveev PTAL

@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 24, 2025
@mlbridge
Copy link

mlbridge bot commented Oct 24, 2025

Webrevs

@openjdk
Copy link

openjdk bot commented Oct 24, 2025

@alexeysemenyukoracle Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information.

Copy link
Member

@sashamatveev sashamatveev left a comment

Choose a reason for hiding this comment

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

Can you update JBS description or this PR to describe additional changes? Based on JBS description: If --icon or --linux-shortcut options are not specified, jpackage should not add .png files to the app image.. Should it be like 2-3 lines fix?


pkg.ifPresent(_ -> {
builder.task(LinuxAppImageTaskID.LAUNCHER_ICONS).noaction().add();
});
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain what this code do? We already have LAUNCHER_ICONS task at line 55. Why we need a second one and without action?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the same task but with a disabled action. Task graph doesn't allow multiple tasks with the same ID.

By default, the LAUNCHER_ICONS task copies launcher icon files to the app image. However, when bundling a native package, this action should not be executed because the DesktopIntegration class adds launcher icons to the package.

Before this change, jpackage copied launcher icon files twice when building a native package: in LAUNCHER_ICONS task and in DesktopIntegration class.

Function name add() is confusing. Should be apply() or commit().

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for explanation. Make sense now. Should we do something like:

if (pkg.isEmpty()) {
.task(LinuxAppImageTaskID.LAUNCHER_ICONS)
                        .addDependent(BuildApplicationTaskID.CONTENT)
                        .applicationAction(LinuxPackagingPipeline::writeLauncherIcons).add();
}

Add task only for application image vs adding it always and then overwriting with noaction()?

Copy link
Member Author

Choose a reason for hiding this comment

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

We can do this, but this will complicate building the task graph by making the set of nodes and edges conditional.

It is simpler to build the graph unconditionally, but configure actions for the nodes conditionally.

E.g.: mac packaging task graph is way more sophisticated in terms of branching, see - MacPackagingPipeline.build(). but its initialization is quite stratighforward.

return this;
}

static <T extends Launcher> ApplicationLaunchers normalizeIcons(
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain why we need this code?

Copy link
Member Author

Choose a reason for hiding this comment

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

Previously, ApplicationImageUtils.createLauncherIconResource() function required the Application instance to get the icon of a launcher because for additional launchers getting icon was a function taking the main launcher into account.

normalizeIcons() modifies application launchers so that they contain complete information about their icons.
The follow-up for this change, ApplicationImageUtils.createLauncherIconResource(), is modified to no longer require an Application instance.

There are other properties in additional launchers that depend on the main launcher: description, shortcuts. Each is calculated in a unique way.

Descripton:

launcherParams.put(DESCRIPTION.getID(), DESCRIPTION.fetchFrom(mainParams));

Shortcuts:

static Optional<LauncherShortcut> findLauncherShortcut(

So we have three functions doing the same thing: they calculate the value of a property of an additionl launcher from the value in the property file of the additional launcher and the value of this property of the main launcher. The logic is the same in all these functions: if an additional launcher doesn't explicitly set the value of a property, it should be copied from the main launcher.

I moved this logic to a single function - ApplicationBuilder.normalizeLauncherProperty(). Currently, it is used for launcher icons only, but later will be used for other launcher poroperties.

Copy link
Member

@sashamatveev sashamatveev 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. Thanks for detailed explanation.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 28, 2025
@alexeysemenyukoracle
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Oct 28, 2025

Going to push as commit 327b7c3.
Since your change was applied there have been 35 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 Oct 28, 2025
@openjdk openjdk bot closed this Oct 28, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Oct 28, 2025
@openjdk
Copy link

openjdk bot commented Oct 28, 2025

@alexeysemenyukoracle Pushed as commit 327b7c3.

💡 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.

2 participants