Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.6.7
    • Fix Version/s: JRuby 1.7.0.pre1
    • Component/s: Java Integration
    • Labels:
    • Environment:
    • Number of attachments :
      0

      Description

      require "java"
      import "java.util.regex.Pattern"
      import "java.util.regex.Matcher"
      s = "hello world"
      r = Pattern.compile("[eo]")
      m = r.matcher(s)
      while m.find()
        puts m.start #=> 1
        puts m.end
        #=> ArgumentError: wrong number of arguments (0 for 1)
        #=> (root) at foo.rb:9
        puts m.end(0) #=> StackOverflow
      end
      

      The call of java.util.regex.Matcher#end with no argument throws an illegal ArgumentError (but java overloads the method with #end() and #end(int)). If I call the method with one argument, a stack overflow occurs.

        Activity

        Hide
        Hiro Asari added a comment -

        #end is not mapped correctly, and we end up with infinite recursion. (See the stack trace here: https://gist.github.com/2259462)

        The workaround is to use #java_send instead:

        m.java_send(:end, [Java::int], 0)
        
        Show
        Hiro Asari added a comment - #end is not mapped correctly, and we end up with infinite recursion. (See the stack trace here: https://gist.github.com/2259462 ) The workaround is to use #java_send instead: m.java_send(:end, [Java:: int ], 0)
        Hide
        Hiro Asari added a comment -

        Actually, the infinite recursion happens here: https://github.com/jruby/jruby/blob/47da0f9967ffb26bd362578984adc5222bc96697/src/builtin/java/java.util.regex.rb#L38-40

        I fixed this on master (3ed20a7) by using #java_send as I described above.

        I should put together a spec.

        Show
        Hiro Asari added a comment - Actually, the infinite recursion happens here: https://github.com/jruby/jruby/blob/47da0f9967ffb26bd362578984adc5222bc96697/src/builtin/java/java.util.regex.rb#L38-40 I fixed this on master (3ed20a7) by using #java_send as I described above. I should put together a spec.
        Hide
        Hiro Asari added a comment -

        Added spec, too. fcc439e

        Show
        Hiro Asari added a comment - Added spec, too. fcc439e

          People

          • Assignee:
            Hiro Asari
            Reporter:
            Kai D
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: