JRuby

Make it clear which Java method maps to each equality method

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: JRuby 1.1b1
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    0

Description

There's some confusion about which Java methods should be redefined/rebound for each of the equality methods. For example, RubyKernel defines ==, eql?, and equal? all to map to obj_equal, and === maps to equal. However Fixnum maps == to an overridden implementation of equal, which calls super.equal. This is incorrect behavior. We need to ensure that all the equality methods map to the correct Java methods, and that we're overriding the right ones in every case.

Issue Links

Activity

Hide
Thomas E Enebo added a comment -

Marcin's comparison script shows a few differences:

missing Method: Symbol#===
missing Method: Proc#==
missing Method: Module#==
extra Method: Time#===
extra Method: Symbol#==
Show
Thomas E Enebo added a comment - Marcin's comparison script shows a few differences:
missing Method: Symbol#===
missing Method: Proc#==
missing Method: Module#==
extra Method: Time#===
extra Method: Symbol#==
Hide
Marcin Mielzynski added a comment -

Fixnum#== maps to overridden implementation of equal (fix_equal equivalent) which by super.equal(...) calls RubyNumeric.equal(...) (MRI num_equal equivalent) - this is correct.

Kernel#==, Kernel#eql?, Kernel#equal? all map to MRI rb_obj_equal
Kernel#=== maps MRI to rb_equal which in turn just calls "==" method

since Kernel#eql? semantics is used by hashes, only Kernel#== and Kernel#equal? can be considered the same (and these should actually map into java's equals method - if they don't do so yet...).

I'll tackle the remaining equality methods posted by Tom.

Show
Marcin Mielzynski added a comment - Fixnum#== maps to overridden implementation of equal (fix_equal equivalent) which by super.equal(...) calls RubyNumeric.equal(...) (MRI num_equal equivalent) - this is correct. Kernel#==, Kernel#eql?, Kernel#equal? all map to MRI rb_obj_equal Kernel#=== maps MRI to rb_equal which in turn just calls "==" method since Kernel#eql? semantics is used by hashes, only Kernel#== and Kernel#equal? can be considered the same (and these should actually map into java's equals method - if they don't do so yet...). I'll tackle the remaining equality methods posted by Tom.
Hide
Charles Oliver Nutter added a comment -

With the patch in JRUBY-540, we get to a point where a fix is needed from this bug.

Show
Charles Oliver Nutter added a comment - With the patch in JRUBY-540, we get to a point where a fix is needed from this bug.
Hide
Charles Oliver Nutter added a comment -

This is largely refactoring, and doesn't appear to have a direct effect on any user apps or code. So it's getting punted to post 1.0.

Show
Charles Oliver Nutter added a comment - This is largely refactoring, and doesn't appear to have a direct effect on any user apps or code. So it's getting punted to post 1.0.
Hide
Marcin Mielzynski added a comment -

Part of this has been done with JRUBY-540, there's no problem to make it a separate work (though it would make JRUBY-540 patch stale)

Show
Marcin Mielzynski added a comment - Part of this has been done with JRUBY-540, there's no problem to make it a separate work (though it would make JRUBY-540 patch stale)
Hide
Charles Oliver Nutter added a comment -

I'm not concerned about the JRUBY-540 patching becoming stale if we can get fixes in that make == and friends more correct...but it would definitely need to be reviewed to include it in 1.0...

Show
Charles Oliver Nutter added a comment - I'm not concerned about the JRUBY-540 patching becoming stale if we can get fixes in that make == and friends more correct...but it would definitely need to be reviewed to include it in 1.0...
Hide
Charles Oliver Nutter added a comment -

I think most of this may have been done already as part of Marcin's recent refactorings. Assigning to Marcin to weigh in on whether we need this bug open anymore.

Show
Charles Oliver Nutter added a comment - I think most of this may have been done already as part of Marcin's recent refactorings. Assigning to Marcin to weigh in on whether we need this bug open anymore.
Hide
Charles Oliver Nutter added a comment -

Fixed remaining naming issues on trunk. The convention is now as follows:

== maps to Java method op_equal
=== maps to Java method op_eqq
eql? maps to Java method eql_p
equal? maps to Java method equal_p
Show
Charles Oliver Nutter added a comment - Fixed remaining naming issues on trunk. The convention is now as follows:
== maps to Java method op_equal
=== maps to Java method op_eqq
eql? maps to Java method eql_p
equal? maps to Java method equal_p

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: