On Mon, 21 Jul 2025 00:11:20 GMT, Chen Liang <li...@openjdk.org> wrote:

>> 8355652: add new method to return ClassFileFormatVersion from 
>> ClassFileVersion.
>> ---------
>> ### Progress
>> - [ ] Change must be properly reviewed (1 review required, with at least 1 
>> [Reviewer](https://openjdk.org/bylaws#reviewer))
>> - [x] Change must not contain extraneous whitespace
>> - [x] Commit message must refer to an issue
>> 
>> 
>> 
>> ### Reviewing
>> <details><summary>Using <code>git</code></summary>
>> 
>> Checkout this PR locally: \
>> `$ git fetch https://git.openjdk.org/jdk.git pull/26406/head:pull/26406` \
>> `$ git checkout pull/26406`
>> 
>> Update a local copy of the PR: \
>> `$ git checkout pull/26406` \
>> `$ git pull https://git.openjdk.org/jdk.git pull/26406/head`
>> 
>> </details>
>> <details><summary>Using Skara CLI tools</summary>
>> 
>> Checkout this PR locally: \
>> `$ git pr checkout 26406`
>> 
>> View PR using the GUI difftool: \
>> `$ git pr show -t 26406`
>> 
>> </details>
>> <details><summary>Using diff file</summary>
>> 
>> Download this PR as a diff file: \
>> <a 
>> href="https://git.openjdk.org/jdk/pull/26406.diff";>https://git.openjdk.org/jdk/pull/26406.diff</a>
>> 
>> </details>
>> <details><summary>Using Webrev</summary>
>> 
>> [Link to Webrev 
>> Comment](https://git.openjdk.org/jdk/pull/26406#issuecomment-3094832141)
>> </details>
>
> src/java.base/share/classes/jdk/internal/classfile/impl/ClassFileVersionImpl.java
>  line 54:
> 
>> 52:     public Optional<ClassFileFormatVersion> formatVersion() {
>> 53:         try {
>> 54:             return 
>> Optional.of(ClassFileFormatVersion.fromMajor(majorVersion));
> 
> You should check the minor version to be 0 for major versions 54 and later.

Do you mean something like this? 


@Override
    public Optional<ClassFileFormatVersion> formatVersion() {
        if (majorVersion >= 54 || minorVersion == 0) {
            return Optional.empty();
        }
        try {
            return Optional.of(ClassFileFormatVersion.fromMajor(majorVersion));
        } catch (IllegalArgumentException e) {
            return Optional.empty();
        }
    }

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26406#discussion_r2218024287

Reply via email to