I just posted to ruby-talk a medium-length discussion of a new idea for solving the Ruby/Java string coercion issue in JRuby. Please go there and participate, since I think it deserves wider attention than the JRuby lists can offer.

The basic gist is this:

Rather than automatically coercing String (and possibly other types) we will coerce according to Ruby protocols; namely, Java integration will define a to_jstring (or to_String, or something) method on Ruby String that will be used to coerce to a JString object. JString will be introduced as the type of Java String entering Ruby code, and it will also obey Ruby coercion protocols by implementing to_str.

Differences for you:

- Calling Java methods with Ruby strings will work as it does today, except that you now have the option to pre-coerce or work with JString to avoid the implicit coercion cost. - Calling Java methods that return String will no longer automatically return Java String, but will return a "String-like" JString object you can then to_str or use directly.

I think long term this is probably going to be the best balance between functionality and performance. The current logic hides too much of a performance hit behind too much magic.

Reply on ruby-talk please :)

- Charlie

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

   http://xircles.codehaus.org/manage_email


Reply via email to