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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2007-03-07 19:13
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
912c61d9da47754de7039f4271334a9f?d=identicon&s=25 MenTaLguY (Guest)
on 2007-03-07 22:05
(Received via mailing list)
On Thu, 8 Mar 2007 03:13:33 +0900, Wes Gamble <weyus@att.net> 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
This topic is locked and can not be replied to.