-
Bug
-
Resolution: Fixed
-
P4
-
17, 19
JVMS §4.10.2.2 (https://docs.oracle.com/javase/specs/jvms/se20/html/jvms-4.html#jvms-4.10.2.2-300) specifies that when merging two operand stacks, int[] and String[] are merged into Object[]:
> If corresponding values are both array reference types, then their dimensions are examined. If the array types have the same dimensions, then the merged value is a reference to an instance of an array type which is first common supertype of both array types. (If either or both of the array types has a primitive element type, then Object is used as the element type instead.) [...]
>
> [...] **Even int[] and String[] can be merged; the result is Object[]**, because Object is used instead of int when computing the first common supertype.
In the first place, Object[] is not a supertype of int[], so this merge does not make any sense.
It can also be does not work when trying to create bytecode that takes the statements in the JVMS at face value (see reproducer).
I did ask on Stack Overflow (https://stackoverflow.com/q/76735066/845414), where I got the answer that "This obviously wrong statement shouldn't exist in the first place.".
> If corresponding values are both array reference types, then their dimensions are examined. If the array types have the same dimensions, then the merged value is a reference to an instance of an array type which is first common supertype of both array types. (If either or both of the array types has a primitive element type, then Object is used as the element type instead.) [...]
>
> [...] **Even int[] and String[] can be merged; the result is Object[]**, because Object is used instead of int when computing the first common supertype.
In the first place, Object[] is not a supertype of int[], so this merge does not make any sense.
It can also be does not work when trying to create bytecode that takes the statements in the JVMS at face value (see reproducer).
I did ask on Stack Overflow (https://stackoverflow.com/q/76735066/845414), where I got the answer that "This obviously wrong statement shouldn't exist in the first place.".