Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.6.7
-
Fix Version/s: JRuby 1.7.0.pre1
-
Component/s: Java Integration
-
Environment:Hidejava version "1.7.0_02"
Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode)
jruby 1.6.7 (ruby-1.8.7-p357) (2012-02-22 3e82bc8) (Java HotSpot(TM) 64-Bit Server VM 1.7.0_02) [linux-amd64-java]Showjava version "1.7.0_02" Java(TM) SE Runtime Environment (build 1.7.0_02-b13) Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode) jruby 1.6.7 (ruby-1.8.7-p357) (2012-02-22 3e82bc8) (Java HotSpot(TM) 64-Bit Server VM 1.7.0_02) [linux-amd64-java]
-
Number of attachments :
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.
#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)