Issue Details (XML | Word | Printable)

Key: JRUBY-1235
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Charles Oliver Nutter
Reporter: Kyle Maxwell
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
JRuby

DRb hangs when transferring Ruby objects created in Java

Created: 24/Jul/07 02:19 PM   Updated: 21/Mar/09 01:14 PM
Component/s: Core Classes/Modules
Affects Version/s: JRuby 1.0.0
Fix Version/s: JRuby 1.2

Time Tracking:
Not Specified

Environment: Mac OS X Tiger


 Description  « Hide
If I use a Java class to create Ruby objects, they cannot be sent over DRb. i.e:
package com.kylemaxwell.development;
import org.jruby.*;
import java.util.*;
public class Fu
{
  public static RubyHash rubyHashPlease()
  {
    Ruby jruby = Ruby.getDefaultInstance();
    HashMap map = new HashMap();
    map.put(
       RubyString.newUnicodeString(jruby,  "foo"), 
      RubyString.newUnicodeString(jruby,  "bar")
    );
    return new RubyHash(jruby, map, new RubyNil(jruby));
  }
}
# jirb
 > require "java"
=> true
 > Fu = com.kylemaxwell.development.Fu
=> Java::ComKylemaxwellDevelopment::Fu
 > Fu.ruby_hash_please
=> {"foo"=>"bar"}
 > Fu.ruby_hash_please
=> {"foo"=>"bar"}
 > Marshal::dump _
=> "\004\010{\006\"\010foo\"\010bar"
 > Marshal::load _
=> {"foo"=>"bar"}
 > require 'drb'
=> true
 > DRb.start_service nil, Fu
=> #<DRb::DRbServer:0x9...
 > DRb.uri
=> "druby://kyle.wan:59476"

# other window...
 > require 'drb'
=> true
 > DRb.start_service
=> #<DRb::DRbServer:0x679f...
>> Fu = DRbObject.new nil, "druby://kyle.wan:59476"
=> #<DRb::DRbObject:0x65bd14 @ref=nil, @uri="druby://kyle.wan:59476">
 > Fu.ruby_hash_please
# Hangs....


 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Charles Oliver Nutter added a comment - 21/Oct/07 10:16 PM
This is because our JavaObject wrapper does not delegate marshalling to Java serialization. We should probably fix this for 1.1, so that Java objects can be marshaled.

Charles Oliver Nutter added a comment - 15/Feb/08 12:58 PM
Punting issues from 1.1 RC2 to 1.1 final.

Charles Oliver Nutter added a comment - 17/Mar/08 01:10 AM
Java integration related, and a bit involved too. Post 1.1.

Riley Lynch added a comment - 28/Dec/08 06:39 PM
See also JRUBY-2128 for another Java object marshalling issue.

Charles Oliver Nutter added a comment - 17/Feb/09 11:47 PM
This works now in JRuby 1.2, since I implemented marshalling for wrapped Java objects using Java serialization.
=> #<DRb::DRbObject:0x4662a3a1 @uri="druby://192.168.0.105:60863", @ref=nil>
irb(main):004:0> Fu.ruby_hash_please
=> {"foo"=>"bar"}