convertToRuby does not work if to_s does not return a String (but for example
nil)
----------------------------------------------------------------------------------
Key: JRUBY-2296
URL: http://jira.codehaus.org/browse/JRUBY-2296
Project: JRuby
Issue Type: Bug
Components: Java Integration
Affects Versions: JRuby 1.1RC2
Environment: Win 2003 Server, Sun JDK 1.6.0_05, JRuby 1.1RC2
Reporter: Benjamin Bock
Priority: Minor
I found this problem while writing a JAXP SAX handler in Ruby but unfortunately
was not able to reproduce it in a smaller environment.
The stacktrace I got is here: http://pastie.org/167296
The first 2 lines of the stacktrace are:
NativeException: java.lang.ClassCastException: org.jruby.RubyNil cannot be cast
to org.jruby.RubyString
from org/jruby/javasupport/JavaUtil.java:204:in `convertRubyToJava'
And an excerpt from JavaUtil.java:
203 // XXX this probably isn't good enough -AM
204 String s = ((RubyString) rubyObject.callMethod(context,
MethodIndex.TO_S, "to_s")).toString();
I think this could be changed to something like
Object o = rubyObject.callMethod(context, MethodIndex.TO_S, "to_s");
String s = null;
if(o instanceOf RubyString) {
s = ((RubyString) o).toString();
} else {
// check for other types like RubyNil
}
--
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