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

W

Wes Gamble

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
 
M

MenTaLguY

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top