FIRST_NONZERO reduction operation is implemented as
this.lane(thisNZ.firstTrue());
VectorMask.firstTrue() returns vector length on all false masks, this leads to Vector.lane(int) throws IllegalArgumentException. The implementation should returns 0 in this occasion instead since FIRST_NONZERO is described as a != 0 ? a : b, which will be 0 if both a and b are 0.
In addition FIRST_NONZERO reduction with a mask throws UnsupportedOperationException, since the there is no support to obtain the reduce identity vector.
this.lane(thisNZ.firstTrue());
VectorMask.firstTrue() returns vector length on all false masks, this leads to Vector.lane(int) throws IllegalArgumentException. The implementation should returns 0 in this occasion instead since FIRST_NONZERO is described as a != 0 ? a : b, which will be 0 if both a and b are 0.
In addition FIRST_NONZERO reduction with a mask throws UnsupportedOperationException, since the there is no support to obtain the reduce identity vector.