HashMap<Integer,...> from Java: unexpected results
--------------------------------------------------

                 Key: JRUBY-4551
                 URL: http://jira.codehaus.org/browse/JRUBY-4551
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
    Affects Versions: JRuby 1.4
         Environment: Windows Vista
            Reporter: maarten mortier


In Java I have a HashMap<Integer, HashMap<...>> that maps record Id's to record 
data.

In jRuby, if I run over this hash:


hash.each do |key, value|
    # hash[key] = nil !
    # hash[java.lang.Integer.new(key)] = value >> OK
end

I think a basic test for jruby should be, for all two-dimensional hashmaps:

assert(hash.all? {|key,value| hash[key] == value })

Similar issue is:
http://www.ruby-forum.com/topic/127884
Hi:

In the following program, the first 'puts' works but the second 'puts'
returns a nil.  If I am accessing a java HashMap that has
java.lang.Integer keys,  is there a simpler way to get values out of the
map than the h.get used with the first 'puts'?

Thanks,
David B.

require "java"
include_class "java.util.HashMap"

h = HashMap.new
h.put(java.lang.Integer.new(1), "aaa")
h.put(java.lang.Integer.new(2), "bbb")

puts h.get(java.lang.Integer.new(1))  # => "aaa" ... OK
puts h.get(1)                         # => nil   ... no go


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to