Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Regression on java array slices with a negative index introduced in 188.8.131.52 #5698
$ jruby --version jruby 184.108.40.206 (2.5.0) 2018-11-06 7b14404 OpenJDK 64-Bit Server VM 25.191-b12 on 1.8.0_191-8u191-b12-2ubuntu0.16.04.1-b12 +jit [linux-x86_64] $ echo $JRUBY_OPTS $ uname -a Linux the_hostname 4.15.0-45-generic #48~16.04.1-Ubuntu SMP Tue Jan 29 18:03:48 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
I expect that slicing Java arrays with negative indexes works like it does in Ruby arrays, or even like it used to work for Java arrays before 220.127.116.11.
See https://ruby-doc.org/core-2.5.0/Array.html#method-i-slice, with emphasis on:
Here is an example of the behavior I would expect:
# Ruby array slicing with a negative index in 18.104.22.168 works fine: jruby-22.214.171.124 :001 > [1,2][0..-1] => [1, 2]
# Java array slicing with a negative index in 126.96.36.199 (last version known to work) works fine: jruby-188.8.131.52 :001 > a = [1,2].to_java[0..-1] => java.lang.Object[1, 2]@1e730495
Instead, what happens is that the last element of the Java array is lost:
# Java array slicing with a negative index in 184.108.40.206 doesn't work any more: jruby-220.127.116.11 :001 > a = [1,2].to_java[0..-1] => java.lang.Object@6a472554
Note that this issue was introduced in 18.104.22.168 and remains in the latest released version 22.214.171.124.
seems like we (I most likely) did the range exclude end condition upside down :
... fix coming for 9.2.8, thanks for bringing this up