RFR: 8338544: Dedicated Array class descriptor implementation [v3]

Mandy Chung mchung at openjdk.org
Tue Oct 8 21:15:59 UTC 2024


On Tue, 8 Oct 2024 21:04:47 GMT, Chen Liang <liach at openjdk.org> wrote:

>> src/java.base/share/classes/jdk/internal/constant/ConstantUtils.java line 313:
>> 
>>> 311:             throw new IllegalArgumentException("rank " + rank + " is not a positive value");
>>> 312:         }
>>> 313:     }
>> 
>> Suggest to inline the rank argument check in the caller method which makes the check explicit to the reader.
>
> So like `if (rank <= 0) throw ConstantUtils.rankNotPositive(rank);` at individual use sites?

I meant no need to have a utility method.   Just do this:

Suggestion:

    public static void validateArrayDepth(int rank) {
        if (rank <= 0) {
            throw new IllegalArgumentException("rank " + rank + " is not a positive value");
        }
        validateMaxArrayDepth(rank, true);
    }


Same change in `ArrayClassDescImpl::arrayType(int)`

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20665#discussion_r1792516398


More information about the core-libs-dev mailing list