Module#alias_method raises exception in some cases when java support has 
already been loaded
--------------------------------------------------------------------------------------------

                 Key: JRUBY-2277
                 URL: http://jira.codehaus.org/browse/JRUBY-2277
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
    Affects Versions: JRuby 1.1RC2
         Environment: Latest JRuby 1.1RC2
            Reporter: Vladimir Sizikov
             Fix For: JRuby 1.1


The following example:

{noformat}
require 'java'
name = Object.new
def name.to_str; "new_name"; end
p String.send("alias_method", name, "to_str")
{noformat}

raises the following:

/jruby.git/lib/ruby/site_ruby/1.8/builtin/javasupport/core_ext/object.rb:107:in 
`method_added': undefined method `to_sym' for #<Object:0x1217e67> 
(NoMethodError)
        from alias.rb:6

When "require 'java'" is removed, everything works fine in JRuby and MRI.

The problem is in object.rb, where to_sym method is invoked, but it is not 
guaranteed to be present, as the example above shows.

This also leads to one rubyspec failure:
{noformat}
1)
Module#alias_method converts a non string/symbol/fixnum name to string using 
to_str ERROR
undefined method `to_sym' for #<MockObject:0xd1c9b5 @name="cinq">:
/opt/work/jruby.git/lib/ruby/site_ruby/1.8/builtin/javasupport/core_ext/object.rb:107:in
 `method_added'
/opt/work/rubinius/./spec/ruby/1.8/core/module/fixtures/classes.rb:161:in 
`make_alias'
/opt/work/rubinius/./spec/ruby/1.8/core/module/alias_method_spec.rb:42
/opt/work/rubinius/./mspec/runner/mspec.rb:111:in `call'
/opt/work/rubinius/./mspec/runner/mspec.rb:111:in `protect'
/opt/work/rubinius/./mspec/runner/state.rb:46:in `each'
/opt/work/rubinius/./mspec/runner/state.rb:46:in `protect'
/opt/work/rubinius/./mspec/runner/state.rb:59:in `process'
/opt/work/rubinius/./mspec/runner/state.rb:55:in `each'
/opt/work/rubinius/./mspec/runner/state.rb:55:in `process'
/opt/work/rubinius/./mspec/runner/mspec.rb:19:in `describe'
/opt/work/rubinius/./mspec/runner/object.rb:11:in `describe'
/opt/work/rubinius/./spec/ruby/1.8/core/module/alias_method_spec.rb:4
/opt/work/rubinius/./mspec/runner/mspec.rb:36:in `load'
/opt/work/rubinius/./mspec/runner/mspec.rb:36:in `files'
/opt/work/rubinius/./mspec/runner/mspec.rb:111:in `call'
/opt/work/rubinius/./mspec/runner/mspec.rb:111:in `protect'
/opt/work/rubinius/./mspec/runner/mspec.rb:36:in `files'
/opt/work/rubinius/./mspec/runner/mspec.rb:33:in `each'
/opt/work/rubinius/./mspec/runner/mspec.rb:33:in `files'
/opt/work/rubinius/./mspec/runner/mspec.rb:26:in `process'
mspec/bin/mspec-ci:30
{noformat}



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to