Java binding takes precedence to application handling for method_missing.
-------------------------------------------------------------------------
Key: JRUBY-3904
URL: http://jira.codehaus.org/browse/JRUBY-3904
Project: JRuby
Issue Type: Bug
Components: Java Integration
Affects Versions: JRuby 1.3
Environment: Mac OS/X, command-line.
Reporter: Gerald Boersma
The JRuby Java binding seems to take precedence to an application's handling
for method_missing.
Consider the JRuby code below. Under Ruby, as expected, the result is the
message "This is what I return from method missing". Under JRuby, it returns
Java::Org. It should return the same result; the Java binding should be last in
precedence for handling method_missing.
Since a require in Ruby is global, a single require 'java' in the application
will result in this behavior. So there is no way to isolate this behavior to
just the code where Java binding is required.
Note: I have not yet considered the technical feasibility of this expected
behavior; I just want to get it out there as a reasonable requirement.
Work-arounds / alternate approaches welcome. I have a work-around in my code
for now, so not a critical for me. I am willing to spend time with this one if
someone directs me to the right place in the JRuby codebase.
# Note: Comment out for Ruby test. Uncomment for JRuby test.
require 'java'
class MethodMissing
def method_missing(m, *args)
puts "method_missing: #{m}."
"This is what I return from method missing."
end
end
mm = MethodMissing.new
result = mm.org
puts "Result: #{result} Type: #{result.class.name}"
--
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