Skip to content

Java::JavaLang::ArrayIndexOutOfBoundsException (invalid bucket size: 0) for Set init with empty array & block #5426

@prashantvithani

Description

@prashantvithani

Environment

Provide at least:

  • jruby 9.2.1.0 (2.5.0) 2018-11-06 7b14404 OpenJDK 64-Bit Server VM 11+28 on 11+28 [darwin-x86_64]

Expected Behavior

Working fine In 9.2.0.0

jruby-9.2.0.0 :003 > Set.new([]) { |e| e }
 => #<Set: {}> 
jruby-9.2.0.0 :004 >

Actual Behavior

Throwing error Java::JavaLang::ArrayIndexOutOfBoundsException (invalid bucket size: 0) When initializing Set with empty array/set and the block is also given

jruby-9.2.1.0 :009 > Set.new([]) { |x| x }
Traceback (most recent call last):
       16: from org.jruby.ir.interpreter.Interpreter.evalCommon(Interpreter.java:172)
       15: from org.jruby.ir.interpreter.Interpreter.INTERPRET_EVAL(Interpreter.java:118)
       14: from org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:72)
       13: from org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:338)
       12: from org.jruby.runtime.callsite.CachingCallSite.callIter(CachingCallSite.java:187)
       11: from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:180)
       10: from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:355)
        9: from org.jruby.RubyClass$INVOKER$i$newInstance.call(RubyClass$INVOKER$i$newInstance.gen)
        8: from org.jruby.RubyClass.newInstance(RubyClass.java:1002)
        7: from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:178)
        6: from org.jruby.ext.set.RubySet$INVOKER$i$initialize.call(RubySet$INVOKER$i$initialize.gen)
        5: from org.jruby.ext.set.RubySet.initialize(RubySet.java:184)
        4: from org.jruby.ext.set.RubySet.initWithEnum(RubySet.java:202)
        3: from org.jruby.ext.set.RubySet.allocHash(RubySet.java:126)
        2: from org.jruby.RubyHash.<init>(RubyHash.java:277)
        1: from org.jruby.RubyHash.allocFirst(RubyHash.java:314)
Java::JavaLang::ArrayIndexOutOfBoundsException (invalid bucket size: 0)
jruby-9.2.1.0 :010 > Set.new([1]) { |x| x }
 => #<Set: {1}> 
jruby-9.2.1.0 :011 > Set.new { |x| x }
 => #<Set: {}> 
jruby-9.2.1.0 :012 > Set.new(Set.new) { |x| x }
Traceback (most recent call last):
       16: from org.jruby.ir.interpreter.Interpreter.evalCommon(Interpreter.java:172)
       15: from org.jruby.ir.interpreter.Interpreter.INTERPRET_EVAL(Interpreter.java:118)
       14: from org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:72)
       13: from org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:338)
       12: from org.jruby.runtime.callsite.CachingCallSite.callIter(CachingCallSite.java:187)
       11: from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:180)
       10: from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:355)
        9: from org.jruby.RubyClass$INVOKER$i$newInstance.call(RubyClass$INVOKER$i$newInstance.gen)
        8: from org.jruby.RubyClass.newInstance(RubyClass.java:1002)
        7: from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:178)
        6: from org.jruby.ext.set.RubySet$INVOKER$i$initialize.call(RubySet$INVOKER$i$initialize.gen)
        5: from org.jruby.ext.set.RubySet.initialize(RubySet.java:184)
        4: from org.jruby.ext.set.RubySet.initWithEnum(RubySet.java:211)
        3: from org.jruby.ext.set.RubySet.allocHash(RubySet.java:126)
        2: from org.jruby.RubyHash.<init>(RubyHash.java:277)
        1: from org.jruby.RubyHash.allocFirst(RubyHash.java:314)
Java::JavaLang::ArrayIndexOutOfBoundsException (invalid bucket size: 0)
jruby-9.2.1.0 :013 >

This seems to be because of #5413

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions