Skip to content

Difference in what caller returns in JRuby 10.1 and Ruby 4.0 #9395

Description

@katafrakt

Environment Information

Provide at least:

  • JRuby: 10.1.0.0
  • OS: Linux

Expected Behavior

MRI 4.0 and JRuby 10.1 return the same number of lines when caller is called.

I know it might fall under "Stack Trace Differences" mentioned in Differences Between MRI and JRuby. If that's expected difference, just let me know.

Between Ruby 3.4 and 4.0 there was a change in what is returned from caller when it's invoked inside initialize.

With this reproduction script (caller.rb):

class Inner
  def initialize
    puts caller
  end
end

class Outer
  def call
    Inner.new
  end
end

Outer.new.call

On Ruby 3.4:

caller.rb:9:in 'Class#new'
caller.rb:9:in 'Outer#call'
caller.rb:13:in '<main>'

On Ruby 4.0:

caller.rb:9:in 'Outer#call'
caller.rb:13:in '<main>'

Actual Behavior

On JRuby 10.1.0.0:

caller.rb:9:in 'new'
caller.rb:9:in 'call'
caller.rb:13:in '<main>'

(same as in 10.0.5.0)

So it's actually the opposite to this part in wiki:

The "new" frame from constructing an object may not be present due to optimizations.

"new" frame is actually present in JRuby, but not in MRI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions