RFR: 8357404: jpackage should attempt to get a package version from the JDK's release file if the --version option is not specified [v6]
Alexander Matveev
almatvee at openjdk.org
Tue Feb 3 23:04:47 UTC 2026
On Mon, 2 Feb 2026 20:00:21 GMT, Alexey Semenyuk <asemenyuk at openjdk.org> wrote:
>> Alexander Matveev has updated the pull request incrementally with one additional commit since the last revision:
>>
>> 8357404: jpackage should attempt to get a package version from the JDK's release file if the --version option is not specified [v6]
>
> src/jdk.jpackage/share/classes/jdk/jpackage/internal/util/RuntimeVersionReader.java line 38:
>
>> 36:
>> 37: public static Optional<String> readVersion(Path releaseFilePath) throws IOException {
>> 38: if (!Files.isRegularFile(releaseFilePath)) {
>
> What is the point of this check? If you remove it and let the function throw an IOException, the function signature can be simplified to `String readVersion(Path releaseFilePath) throws IOException`. Making it clear that the function either returns a valid JDK version or throws.
>
> If you don't want to deal with handling exceptions in the caller, you can implement it without throwing:
>
> Optional<String> readVersion(Path releaseFilePath) {
> try {
> ...
> return Optional.of(version);
> } catch (IOException ex) {
> return Optional.empty();
> }
> }
>
> Currently, it is a confusing mix of both approaches.
Will be implemented without throwing.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/29260#discussion_r2761396784
More information about the core-libs-dev
mailing list