Can't Marshal.dump a Java object (from using Rjb)

Discussion in 'Ruby' started by Wes Gamble, Mar 7, 2007.

  1. Wes Gamble

    Wes Gamble Guest

    All,

    I have a Ruby object that actually encapsulates a Java object - I got it
    by using Rjb to talk to a Java library.

    When I attempt to marshal it, I get the following error:

    "can't dump anonymous class"

    If Rjb returned a named class instead of an anonymous one, would I then
    be able to marshal it?

    BTW, why can't anonymous classes be dumped?

    Thanks,
    Wes

    --
    Posted via http://www.ruby-forum.com/.
    Wes Gamble, Mar 7, 2007
    #1
    1. Advertising

  2. Wes Gamble

    MenTaLguY Guest

    On Thu, 8 Mar 2007 03:13:33 +0900, Wes Gamble <> wrote:
    > If Rjb returned a named class instead of an anonymous one, would I then
    > be able to marshal it?


    No, not at this time. It isn't even technically feasible to implement unless the Java object being wrapped belongs to a class which supports Java serialization (i.e. implements java.io.Serializable).

    > BTW, why can't anonymous classes be dumped?


    A class name is required by Ruby's marshal format, since otherwise there would be no way to determine which class to use when loading the marshalled object. Remember that a dumped object may be loaded in a different interpreter instance than the one that dumped it.

    -mental
    MenTaLguY, Mar 7, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    10
    Views:
    530
    Aaron Watters
    Jun 18, 2008
  2. Michael Davis

    Ruby 1.8 and Marshal.load/Marshal.dump

    Michael Davis, Oct 10, 2003, in forum: Ruby
    Replies:
    0
    Views:
    167
    Michael Davis
    Oct 10, 2003
  3. Alex Gutteridge

    Marshal.dump - anonymous module

    Alex Gutteridge, Feb 12, 2004, in forum: Ruby
    Replies:
    3
    Views:
    265
  4. benny
    Replies:
    1
    Views:
    156
    Evan Webb
    Apr 25, 2005
  5. Nathan Baker
    Replies:
    10
    Views:
    247
Loading...

Share This Page