[jruby] Bug in JRuby IRB - Windows?

Rodrigo Botafogo rodrigo at rodrigobotafogo.com
Wed Jul 22 05:43:43 JST 2015


Hello….

I have implemented a Critbit tree (Binary Patricia Trie) for JRuby. A
Critbit can substitute a Hash and my implmenetation interface is actually
the same as Hash. The implementation uses a critbit java library. I
developed in Cygwin and have tested it. and it works fine. I generated a
gem (not yet published - it is available on github -
https://github.com/rbotafogo/Critbit - and I can publish it if this might
help find the bug) and loaded it in JRuby for windows with:

jruby -S gem install critbit

Installation went fine. Now the strange think.

If I start jirb on the Windows (DOS) console and use the library everything
works fine. However, if I start the JRuby IRB application and run my code I
get the following error:

NoMethodError: undefined method traverse' for {"a"=>1,
"b"=>2}:Java::IoPrelinkCritbit::MCritBitTree from
C:/jruby-9.0.0.0.rc2/lib/ruby/gems/shared/gems/critbit-0.5.0-java/lib/critbit.rb:587:in
_get’
from
C:/jruby-9.0.0.0.rc2/lib/ruby/gems/shared/gems/critbit-0.5.0-java/lib/critbit.rb:525:in
values' from (irb):5:in‘
from org/jruby/RubyKernel.java:979:in eval' from
org/jruby/RubyKernel.java:1292:inloop’
from org/jruby/RubyKernel.java:1099:in catch' from
org/jruby/RubyKernel.java:1099:incatch’
from C:\jruby-9.0.0.0.rc2\/bin/jirb_swing:63:in `‘

The code is:

require 'critbit'

crit = Critbit.new
crit["a"] = 1
crit["b"] = 2
p crit

Method traverse in not implemented in the MCritbitTree class but on it´s
superclass:

public final class MCritBitTree<K,V> extends AbstractCritBitTree<K,V>
implements Map<K,V> {

...}

and as can be seen from the error message the data has been properly stored
on the critbit {“a”=>1, “b”=>2} and to print that, it seems that method
'traverse' was actually used.

Now, why would the same application work on jirb and not on the JRuby IRB?
I get this behaviour both on jruby 9000 as with jruby 1.7.21. Is this a bug
or could I have done something wrong?

Thanks….
​
-- 
Rodrigo Botafogo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ruby-lang.org/pipermail/jruby/attachments/20150721/bbdbe204/attachment-0001.html>


More information about the JRuby mailing list