Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.6.7
    • Fix Version/s: JRuby 1.7.0.pre2
    • Component/s: Java Integration
    • Labels:
      None
    • Environment:
      jruby 1.6.7 (ruby-1.8.7-p357) (2012-02-22 3e82bc8) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_31) [linux-amd64-java]
    • Number of attachments :
      1

      Description

      If I try java.util.Collections.shuffle on a ruby array, I get a strange result.

      I attached an example code for it

      Actual result:

      Ruby array

      Original: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
      Shuffled: [0, 3, 6, 7, 7, 7, 7, 9, 9, 10, 10]

      Java array

      Original: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
      Shuffled: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

        Activity

        Hide
        Charles Oliver Nutter added a comment -

        Confirmed, but I have no theory yet.

        Show
        Charles Oliver Nutter added a comment - Confirmed, but I have no theory yet.
        Hide
        Charles Oliver Nutter added a comment -
        commit ed738357bdf1385b7d3555f0d94ea020ecdbc8d5
        Author: Charles Oliver Nutter <headius@headius.com>
        Date:   Tue Jun 12 15:44:55 2012 -0500
        
            Fix JRUBY-6706
            
            Collections.shuffle works incorreclty on Ruby arrays
            
            We were not implementing List.set properly; it should return the
            previous value at that index, and we were just returning the
            given value.
        
        Show
        Charles Oliver Nutter added a comment - commit ed738357bdf1385b7d3555f0d94ea020ecdbc8d5 Author: Charles Oliver Nutter <headius@headius.com> Date: Tue Jun 12 15:44:55 2012 -0500 Fix JRUBY-6706 Collections.shuffle works incorreclty on Ruby arrays We were not implementing List.set properly; it should return the previous value at that index, and we were just returning the given value.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: