Including Java interfaces doesn't work in some cases
----------------------------------------------------
Key: JRUBY-3438
URL: http://jira.codehaus.org/browse/JRUBY-3438
Project: JRuby
Issue Type: Bug
Components: Java Integration
Affects Versions: JRuby 1.1.6
Reporter: David R. MacIver
These may be unrelated issues, but I found one when investigating the other.
Neither of the following work:
{{
require "java"
CS = Java::JavaLang::CharSequence
class Proc
include CS
end
def foo(&p)
p
end
a = foo{|x| x}
puts a.is_a? CS
Java::JavaLang::String.new("foo").content_equals(a)
}}
results in:
{{
true
demo.rb:16: for method contentEquals expected [java.lang.CharSequence]; got:
[org.jruby.RubyProc]; error: argument type mismatch (TypeError)
}}
while
{{
require "java"
CS = Java::JavaLang::CharSequence
a = Object.new
class <<a
include CS
end
puts a.is_a? CS
Java::JavaLang::String.new("foo").content_equals(a)
}}
results in
{{
true
demo.rb:13: for method contentEquals expected [java.lang.CharSequence]; got:
[org.jruby.RubyObject]; error: argument type mismatch (TypeError)
}}
i.e. in both cases despite the fact that is_a? CharSequence is returning true,
trying to pass it to a Java method expecting a CharSequence results in a type
error (obviously it would still fail with missing methods if it weren't a type
error. I just picked an example at random to demonstrate the problem)
In the Proc case replacing the Proc created from the block with an explicit
Proc.new works, which works around the issue I was seeing.
--
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