jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • JRuby
  • JRUBY-2557

NPE when yielding method

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: JRuby 1.1.1
  • Fix Version/s: JRuby 1.2
  • Component/s: Interpreter
  • Labels:
    None
  • Environment:
    Ubuntu Gutsy, java-6-sun-1.6.0.03

Description

#The last line throws NPE at org.jruby.runtime.callback.ReflectionCallback.execute(ReflectionCallback.java:138)
# Under MRI (1.8.6) it works fine.
class A
  def a
    p "hello"
  end
end

def y 
  yield
end

p = A.new.method :a

p.call
y(&p)

Activity

  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Charles Oliver Nutter added a comment - 14/Feb/09 12:54 PM

Thanks for the softball issue! I'm surprised this never came up; people must not use Method#to_proc on methods that take no arguments very often. The problem was that yield passes null internally when there are no args, but the block logic for the to_proc'ed method expected there to always be arguments. It tried to then use the arguments to access JRuby runtime information, and blew up. The fix was to add a path for null to pass zero arguments along to the method and get the runtime information in another way. I added a rubyspec in 8e638250aea9b32fe2b5de2e0ae4a1d7f2f2708c and committed a fix plus rubyspec update to JRuby in r9146.

Show
Charles Oliver Nutter added a comment - 14/Feb/09 12:54 PM Thanks for the softball issue! I'm surprised this never came up; people must not use Method#to_proc on methods that take no arguments very often. The problem was that yield passes null internally when there are no args, but the block logic for the to_proc'ed method expected there to always be arguments. It tried to then use the arguments to access JRuby runtime information, and blew up. The fix was to add a path for null to pass zero arguments along to the method and get the runtime information in another way. I added a rubyspec in 8e638250aea9b32fe2b5de2e0ae4a1d7f2f2708c and committed a fix plus rubyspec update to JRuby in r9146.

People

  • Assignee:
    Charles Oliver Nutter
    Reporter:
    Tamas de J
Vote (0)
Watch (2)

Dates

  • Created:
    23/May/08 5:35 AM
    Updated:
    21/Mar/09 1:14 PM
    Resolved:
    14/Feb/09 12:54 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.