# Problems reading Java Hashtables from Jruby 1.3.1

**URL:** <https://www.ruby-forum.com/t/problems-reading-java-hashtables-from-jruby-1-3-1/170831>\
**Category:** JRuby\
**Created:** [June 23, 2009, 9:25am UTC](https://www.ruby-forum.com/t/problems-reading-java-hashtables-from-jruby-1-3-1/170831 "2009-06-23T09:25:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![eipipuz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/bbe5ce/32.png) [@eipipuz](https://www.ruby-forum.com/u/eipipuz)\
**Post date:** [June 23, 2009, 9:25am UTC](https://www.ruby-forum.com/t/problems-reading-java-hashtables-from-jruby-1-3-1/170831/1 "2009-06-23T09:25:18Z")

</div>

Hello guys,

I am having a big problem and it looks like a bug in jruby.

I have two java hash tables: hash1 and hash2. Both hashes have the same  
key  
but different data. Both hashes are generated in Java classes executed  
from  
Ruby code. Then I need to read a process both hashes within the ruby  
code,  
so I do the following:

hash1.each { |key, data|  
puts hash2  
puts hash2[key]  
}

All the first puts print the complete list of key/value pairs without  
any  
problems. The second line is NIL. Why?

Thanks in advance,

GA

---

<div class="post-metadata">

**Author:** ![eipipuz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/bbe5ce/32.png) [@eipipuz](https://www.ruby-forum.com/u/eipipuz)\
**Post date:** [June 23, 2009, 4:54pm UTC](https://www.ruby-forum.com/t/problems-reading-java-hashtables-from-jruby-1-3-1/170831/2 "2009-06-23T16:54:13Z")

</div>

On Tue, Jun 23, 2009 at 2:24 AM, Guillermo A.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> puts hash2  
> puts hash2[key]  
> }
> 
> All the first puts print the complete list of key/value pairs without any  
> problems. The second line is NIL. Why?

It sounds like a bug to me too. If you could make a small reproduction  
with  
a simple Java class and a Ruby script and attach to a JIRA, that would  
great!

[http://jira.codehaus.org/browse/JRUBY](http://jira.codehaus.org/browse/JRUBY)

/Nick

---

<div class="post-metadata">

**Author:** ![eipipuz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/bbe5ce/32.png) [@eipipuz](https://www.ruby-forum.com/u/eipipuz)\
**Post date:** [June 23, 2009, 5:08pm UTC](https://www.ruby-forum.com/t/problems-reading-java-hashtables-from-jruby-1-3-1/170831/3 "2009-06-23T17:08:18Z")

</div>

Nick S. wrote:

> ```
> hashes within the ruby code, so I do the following:
> 
> ```
> 
> It sounds like a bug to me too. If you could make a small reproduction  
> with a simple Java class and a Ruby script and attach to a JIRA, that  
> would great!

Make sure also you’re seeing what you THINK you’re seeing. “puts” can be  
deceiving.

> ruby -e ‘a = {“6”, 10}; b = {6, 10}; puts a; puts b; p a; p b’  
> 610  
> 610  
> {“6”=\>10}  
> {6=\>10}

* * *

To unsubscribe from this list, please visit:

```
http://xircles.codehaus.org/manage_email

```
