RFR: 8288838: jpackage: file association additional arguments

Alex Kasko akasko at openjdk.org
Wed Jun 29 12:58:27 UTC 2022


On Tue, 28 Jun 2022 21:38:50 GMT, Alexey Semenyuk <asemenyuk at openjdk.org> wrote:

> The existing behavior simply cuts off all, but the first argument from the argument array passed to the app launcher. Changing this looks more like a fix of a bug, than an enhancement. I'd keep it simple: replace the value of the `Argument` attribute from `%1` to `%*`. Besides, `"%1 %*"` seems to duplicate the first argument (`%1` is not referencing a path to app launcher executable, but the name of a file to open). If fixed in this way, we don't need to introduce `pass-all-args`.

I've experimented with this, used following example app:

 - `hello.jar` - java application
 - `hello.exe` - launcher created by jpackage
 - `hello.foo` - file with a `.foo` extension associated with `hello.exe`

Arguments placeholders specified In a `progid[...]\shell\open\command` registry entry are received in java app in a following form:

 - `%0` points to `c:\path\too\hello.foo`, that is a selected file path (for context menu invocation) or a `shortcut.TargetPath` property (for `LNK` shortcut invocation)
 - `%1` is the same as `%0` 
 - `%2` points to the first argument in `shortcut.Arguments` property
 - `%*` contains all the arguments beginning from `%2`

`%1` must be quoted, otherwise it only contains the part of path before the first space and other path parts are passed as `%2` and following arguments.

`%*` must not be quoted, it passes arguments with spaces correctly.

Based on the above I've updated the patch dropping the property and changing the `Argument` to `"%1" %*`.

I would appreciate the guidance on the test changes (note, `packageTest.forTypes` and `packageTest.run` changes are temporary). Foremost, should we cover all three ways to invoke the associated file (command line, desktop open associated file, desktop open LNK) and (if yes) should they be split into separate test runs?

-------------

PR: https://git.openjdk.org/jdk/pull/9224


More information about the core-libs-dev mailing list