Auto java interface coercion for vanilla ruby objects
-----------------------------------------------------
Key: JRUBY-991
URL: http://jira.codehaus.org/browse/JRUBY-991
Project: JRuby
Issue Type: New Feature
Components: Java Integration
Affects Versions: JRuby 1.0.0RC2
Reporter: Nick Sieger
This patch will allow plain Ruby objects to be passed to Java method arguments
that are interface types, and the Ruby object will automatically be wrapped in
an interface proxy, [as originally proposed
here|http://blog.nicksieger.com/articles/2006/12/01/rspec-jruby-mocking-and-multiple-interfaces].
Another example:
{code}
include Java
filter = Object.new
def filter.accept(file, str)
!!(str =~ /jar/)
end
file = java.io.File.new("lib")
file.list(filter).each {|f| puts f}
{code}
I still think this approach has a place alongside the rest of the recently
revamped java integration. It's somewhat of an edge case in that the code will
only be activated when you pass a vanilla Ruby object to Java; I think the
chance for unexpected surprises is low.
--
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