New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
java.util.ArrayList#include?
returns false incorrectly (9.1.3.0 onwards)
#5569
Comments
... and use contains(Object) directly as the (Enumerable) base impl loops over the collection making it highly non-effective (e.g. for sets) 9.0.5.0 ``` user system total real ArrayList#include? hit 11.670000 1.150000 12.820000 ( 11.749035) ArrayList#include? miss 9.840000 0.080000 9.920000 ( 9.707464) ArrayList#contains hit 0.730000 0.010000 0.740000 ( 0.370432) ArrayList#contains miss 0.350000 0.000000 0.350000 ( 0.267981) HashSet#include? hit 13.720000 0.020000 13.740000 ( 13.593915) HashSet#include? miss 9.610000 0.020000 9.630000 ( 9.543065) HashSet#contains hit 0.410000 0.000000 0.410000 ( 0.256134) HashSet#contains miss 0.290000 0.000000 0.290000 ( 0.213409) LHashSet#include? hit 11.560000 0.020000 11.580000 ( 11.453787) LHashSet#include? miss 11.840000 0.010000 11.850000 ( 11.752156) LHashSet#contains hit 0.320000 0.000000 0.320000 ( 0.227460) LHashSet#contains miss 0.310000 0.000000 0.310000 ( 0.220113) ``` before ``` user system total real ArrayList#include? hit 3.060000 0.000000 3.060000 ( 3.057502) ArrayList#include? miss 3.220000 0.010000 3.230000 ( 3.232130) ArrayList#contains hit 0.310000 0.000000 0.310000 ( 0.308007) ArrayList#contains miss 0.320000 0.000000 0.320000 ( 0.313187) HashSet#include? hit 3.040000 0.000000 3.040000 ( 3.036603) HashSet#include? miss 3.240000 0.010000 3.250000 ( 3.237065) HashSet#contains hit 0.160000 0.000000 0.160000 ( 0.152719) HashSet#contains miss 0.150000 0.000000 0.150000 ( 0.154513) LHashSet#include? hit 3.000000 0.000000 3.000000 ( 2.987810) LHashSet#include? miss 3.160000 0.000000 3.160000 ( 3.165118) LHashSet#contains hit 0.160000 0.000000 0.160000 ( 0.160286) LHashSet#contains miss 0.230000 0.000000 0.230000 ( 0.156899) ``` after ``` user system total real ArrayList#include? hit 0.110000 0.000000 0.110000 ( 0.098661) ArrayList#include? miss 0.090000 0.000000 0.090000 ( 0.087545) ArrayList#contains hit 0.350000 0.000000 0.350000 ( 0.352668) ArrayList#contains miss 0.350000 0.000000 0.350000 ( 0.351055) HashSet#include? hit 0.070000 0.000000 0.070000 ( 0.061353) HashSet#include? miss 0.060000 0.000000 0.060000 ( 0.058946) HashSet#contains hit 0.180000 0.000000 0.180000 ( 0.172549) HashSet#contains miss 0.170000 0.000000 0.170000 ( 0.171588) LHashSet#include? hit 0.090000 0.000000 0.090000 ( 0.071044) LHashSet#include? miss 0.070000 0.000000 0.070000 ( 0.060303) LHashSet#contains hit 0.300000 0.000000 0.300000 ( 0.208889) LHashSet#contains miss 0.170000 0.000000 0.170000 ( 0.166072) ```
interesting find, still I would consider the previous behaviour invalid and not inline with Ruby types.
previous functionality meant always going through a collection - so also if you need the previous behaviour you could transplant |
I would expect
However, in the case I reported, the equality operator returns true, making the behavior of
|
[16] pry(main)> 7 == java.lang.Integer.new(7)
=> false 7 is not equal as java.lang.Integer.new(7), maybe that's the point |
@googya JRuby supports automatic conversion between Java and Ruby types under certain circumstances but not all. However, equality and inclusion should be consistent for any given case, but in the case I reported, they are not. |
I did a git bisect and traced this to commit 2e47a9d
Environment
JRuby version: All versions from 9.1.3.0 onwards
Operating system and platform:
Expected Behavior
When I insert a
java.lang.Integer
into ajava.util.ArrayList
and pass the corresponding Ruby Fixnum to#include?
, I expect it to return trueActual Behavior
Starting with jruby 9.1.3.0, it returns false
The text was updated successfully, but these errors were encountered: