Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.6.6, JRuby 1.6.7
    • Fix Version/s: JRuby 1.7.0.pre1
    • Component/s: Core Classes/Modules
    • Labels:
    • Environment:
      Fedora 14
      jruby 1.6.7 (ruby-1.9.2-p312) (2012-02-22 3e82bc8) (OpenJDK 64-Bit Server VM 1.6.0_20) [linux-amd64-java]
    • Number of attachments :
      1

      Description

      When a Fixnum array is created, join works as expected:

      a = [1,2,3,4]
      a.join('.') -> "1.2.3.4"
      

      When a sub-list is created from an existing Fixnum array, join fails.

      b = a[2,3]
      b.join('.') ->
      TypeError: can't convert Fixnum into String
      	from org/jruby/RubyArray.java:1871:in `join'
      	from ...
      	from org/jruby/RubyKernel.java:1088:in `eval'
      	from org/jruby/RubyKernel.java:1410:in `loop'
      	from org/jruby/RubyKernel.java:1197:in `catch'
      	from org/jruby/RubyKernel.java:1197:in `catch'
      	from ...
      

      This behaviour only occurs in 1.9 compatibility mode, not 1.8. It occurs in both JRuby 1.6.6 and 1.6.7.
      Verified expected behaviour in Ruby 1.8.7; 1.9.3; and JRuby 1.6.7 in 1.8 compatibility mode.

      I suspect that the array returned from a subset specification is in some way different than a regularly declared array. I inspected the class and ancestry and they look identical, but the behaviour is clearly different.

      The line above in RubyArray.java points to the "join19" method.

        Activity

        Hide
        Hiro Asari added a comment -

        I do not see this behavior.

        $ cat Downloads/array_join_fail_example.rb
        p RUBY_DESCRIPTION
        a = [1,2,3,4] # Create a normal array
        p a.join('.')   # -> "1.2.3.4" # Works as expected
        b = a[2,3]    # get sublist; suspect that b is somehow not exactly
                      # the same class type, though it appears to be a normal array.
        p b.join('.')   # ->
        #TypeError: can't convert Fixnum into String
        #	from org/jruby/RubyArray.java:1871:in `join'
        #	from ...
        #	from org/jruby/RubyKernel.java:1088:in `eval'
        #	from org/jruby/RubyKernel.java:1410:in `loop'
        #	from org/jruby/RubyKernel.java:1197:in `catch'
        #	from org/jruby/RubyKernel.java:1197:in `catch'
        #	from ...
        
        $ jruby Downloads/array_join_fail_example.rb
        "jruby 1.6.7 (ruby-1.8.7-p357) (2012-02-22 3e82bc8) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_29) [darwin-x86_64-java]"
        "1.2.3.4"
        "3.4"
        
        Show
        Hiro Asari added a comment - I do not see this behavior. $ cat Downloads/array_join_fail_example.rb p RUBY_DESCRIPTION a = [1,2,3,4] # Create a normal array p a.join('.') # -> "1.2.3.4" # Works as expected b = a[2,3] # get sublist; suspect that b is somehow not exactly # the same class type, though it appears to be a normal array. p b.join('.') # -> #TypeError: can't convert Fixnum into String # from org/jruby/RubyArray.java:1871:in `join' # from ... # from org/jruby/RubyKernel.java:1088:in `eval' # from org/jruby/RubyKernel.java:1410:in `loop' # from org/jruby/RubyKernel.java:1197:in `catch' # from org/jruby/RubyKernel.java:1197:in `catch' # from ... $ jruby Downloads/array_join_fail_example.rb "jruby 1.6.7 (ruby-1.8.7-p357) (2012-02-22 3e82bc8) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_29) [darwin-x86_64-java]" "1.2.3.4" "3.4"
        Hide
        Daniel Jackson added a comment -

        You executed in 1.8.7 mode. It fails in 1.9.2.

        Show
        Daniel Jackson added a comment - You executed in 1.8.7 mode. It fails in 1.9.2.
        Hide
        Hiro Asari added a comment -

        You're right. The problem exists, but it's fixed in master. I see a lot of commits going into RubyArray.java, but I suspect it is just a matter of coming up with a feasible patch.

        Show
        Hiro Asari added a comment - You're right. The problem exists, but it's fixed in master. I see a lot of commits going into RubyArray.java, but I suspect it is just a matter of coming up with a feasible patch.
        Hide
        Charles Oliver Nutter added a comment -

        This was fixed as of 1.7pre1.

        Show
        Charles Oliver Nutter added a comment - This was fixed as of 1.7pre1.

          People

          • Assignee:
            Charles Oliver Nutter
            Reporter:
            Daniel Jackson
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: