jruby/jruby — pull request #1356 by DavidEGrayson (2013-12-23 00:37:10+00:00)
Title: Use RubyString's eql method in SymbolTable to look up symbols (first attempt to fix #1348)

This pull request is my first attempt to fix issue #1348. The problem was that the methods for looking up symbols in the SymbolTable did not account for the encoding specified by the caller. This pull request fixes issue #1348 by storing a RubyString in the symbol table and using RubyString#eql to find a symbol matching the request from the caller.

Since the SymbolTable is operating in a very different way now, I had to remove a lot of code from it that seemed to be there for optimization. There were three or four different ways of retrieving entries from the table; I have reduced that down to one so I could easily change it.

Also, to ensure that typical ASCII-only symbols continue to be equal in the expected way, I added code in SymbolTable#normalizeString that, like MRI's `intern_str`, checks to see if the string can be converts the string to US-ASCII if possible.

This change fixes the issue, and I was able to run the JRuby continuous integration tests mostly successfully on my computer before and after the change was applied.

If this pull request is OK, I think I would like to go further. I am nervous about keeping this strange Java string around inside the RubySymbol object named `symbol` because it does not hold any information about the symbol's encoding; I would want to just store a RubyString there instead. I would also like to get a grasp on the many different ways there are to create symbols and maybe get rid of some.