RFR: 8279995: jpackage --add-launcher option should allow overriding description [v4]

Alexander Matveev almatvee at openjdk.java.net
Fri Feb 25 01:38:16 UTC 2022


On Thu, 17 Feb 2022 17:53:57 GMT, Alexey Semenyuk <asemenyuk at openjdk.org> wrote:

>> Alexander Matveev has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   8279995: jpackage --add-launcher option should allow overriding description [v4]
>
> test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java line 165:
> 
>> 163: 
>> 164:         return description;
>> 165:     }
> 
> How about this:
> 
> public static String getExecutableDesciption(Path pathToExeFile) {
>         Executor exec = Executor.of("powershell",
>                 "-NoLogo",
>                 "-NoProfile",
>                 "-Command",
>                 "(Get-Item \\""
>                 + pathToExeFile.toAbsolutePath()
>                 + "\\").VersionInfo | select FileDescription");
> 
>         var lineIt = exec.dumpOutput().executeAndGetOutput().iterator();
>         while (lineIt.hasNext()) {
>             var line = lineIt.next();
>             if (line.trim().equals("FileDescription")) {
>                 // Skip "---------------" and move to the description value
>                 lineIt.next();
>                 var description = lineIt.next().trim();
>                 if (lineIt.hasNext()) {
>                     throw new RuntimeException("Unexpected input");
>                 }
>                 return description;
>             }
>         }
> 
>         throw new RuntimeException(String.format(
>                 "Failed to get file description of [%s]", pathToExeFile));
>     }
> 
> Added `Executor.dumpOutput()` call to save the output of powershell command in the test log for easier debugging.
> No null initialized `description` variable. No iteration over the list using the index. Check for the end of the output.

Fixed. Except I removed if (lineIt.hasNext()) { throw new RuntimeException("Unexpected input");  }, since there are empty lines after description in output and this check triggers exception.

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

PR: https://git.openjdk.java.net/jdk/pull/7399


More information about the core-libs-dev mailing list