Skip to content
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

Symbol eql? returning false incorrectly #1610

Closed
chriseppstein opened this issue Apr 4, 2014 · 5 comments
Closed

Symbol eql? returning false incorrectly #1610

chriseppstein opened this issue Apr 4, 2014 · 5 comments

Comments

@chriseppstein
Copy link

I've got the following ruby code:

puts "#{key.inspect} == #{type.inspect}. hashes: #{key.hash}/#{type.hash} types: #{key.class}/#{type.class} =?= #{key == type} | eql? #{key.eql?(type)}. #{key.to_s.bytes.to_a.inspect}  #{type.to_s.bytes.to_a.inspect}"

Which produces the following output:

:uri == :uri. hashes: 971699949/971699949 types: Symbol/Symbol =?= true | eql? false. [117, 114, 105]  [117, 114, 105]

Note that eql? is returning false for these two values. when everything else points to them being the exact same symbol. The symbols in question are defined in two different ruby files but both are part of the same ruby gem. the key symbol was declared in a class context while the type symbol was referenced in an instance context.

Running against jruby-complete-1.7.11.jar.

This jar file can reproduce the issue:
https://github.com/chriseppstein/misc/blob/master/junkdrawer/class_loader_importer_test.jar

with the following command:

java -cp jruby-complete-1.7.11.jar:class_loader_importer_test.jar ClassLoaderImporterTest
@chriseppstein
Copy link
Author

Also:

$ java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

@headius
Copy link
Member

headius commented Apr 7, 2014

Is it possible you're getting symbols from two different JRuby instances in the same code? They would appear to be identical, but because they're from different instances they'd be different objects.

I might also suspect encoding, but the symbols appear to have the same bytes here.

@chriseppstein
Copy link
Author

@headius I had this thought. I'm fairly certain it's a single jruby instance. But I don't know how to check this.

@thedarkone
Copy link
Contributor

@chriseppstein try JRuby.reference0(key).runtime (though not an expert here).

@headius
Copy link
Member

headius commented Apr 27, 2017

We've had a lot of changes in the past three years and no followup after last suggestion. Closing.

@headius headius closed this as completed Apr 27, 2017
@headius headius added this to the Invalid or Duplicate milestone Apr 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants