[vector] Error message in the fromArray length check is misleading

Adam Pocock adam.pocock at oracle.com
Thu Jan 31 16:45:20 UTC 2019


So that would mean replacing VectorIntrinsics line 405:
     case 2: return Objects.checkIndex(ix, length - (vlen - 1));
with:
     case 2: return Preconditions.checkIndex(ix, length - (vlen - 1), 
(String kind, List<Integer> vals) -> new 
IndexOutOfBoundsException(String.format("Index %d out of bounds for 
length %d",vals.get(0)+(vlen-1),vals.get(1)+(vlen-1))));

I think you'd need to capture vlen to recover the correct end values for 
the indices, which makes it rather ugly. Maybe it could be moved onto 
the vectors themselves, that way the lambda could be static and it would 
pick up a static vlen?

Adam

On 30/01/2019 17:39, John Rose wrote:
> On Jan 30, 2019, at 2:09 PM, Vladimir Ivanov 
> <vladimir.x.ivanov at oracle.com <mailto:vladimir.x.ivanov at oracle.com>> 
> wrote:
>>
>> So, I'm in favor of improving error message itself leaving the check 
>> as is for now.
>>
>
> This occasion was anticipated in the design of the Preconditions API.
> You can plug in your own error reporter as a lambda, without abandoning
> the intrinsic behavior.

-- 
Adam Pocock
Principal Member of Technical Staff
Machine Learning Research Group
Oracle Labs, Burlington, MA



More information about the panama-dev mailing list