On Fri, 27 Mar 2026 13:19:20 GMT, Frederic Parain <[email protected]> wrote:

>> src/java.base/share/classes/java/lang/invoke/ArrayVarHandle.java line 123:
>> 
>>> 121:         Object[] array = (Object[]) handle.arrayType.cast(oarray);
>>> 122:         Class<?> arrayType = oarray.getClass();
>>> 123:         if (ValueClass.isFlatArray(array)) {
>> 
>> I'd like to get extra scrutiny of this change.
>
> What is your concern?

My concern is that I don't fully understand why the code the way it does, and 
it looks a little bit funny.

For example:

       Object[] array = (Object[]) handle.arrayType.cast(oarray);
       Class<?> arrayType = oarray.getClass();
       if (ValueClass.isFlatArray(array)) {


It performs a cast to get an `array` reference, but then it uses the `oarray` 
reference to fetch the `arrayType` (and the same for the isFlatArray call that 
I'm changing).

I would think that the could look like this:

       Object[] array = (Object[]) handle.arrayType.cast(oarray);
       Class<?> arrayType = array.getClass();
       if (ValueClass.isFlatArray(array)) {

but I'm not sure if that is missing some very subtle detail that is important 
for the code.

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

PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2261#discussion_r3001044601

Reply via email to