Forum: JRuby Custom marshal_dump problems

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.
F8101d1b395ef58feb1d5c99bf9356df?d=identicon&s=25 Jim Menard (Guest)
on 2008-11-20 22:21
(Received via mailing list)
I've written my own marshal_dump method for a class, in Java. When it
gets called, a ClassCastException is thrown. Here's the top of the
stack trace:

java.lang.ClassCastException: org.jruby.RubySymbol
  at
ed.lang.ruby.RubyObjectIdWrapper$i_method_0_0$RUBYINVOKER$marshal_dump.call(ed/lang/ruby/RubyObjectIdWrapper$i_method_0_0$RUBYINVOKER$marshal_dump.gen)
  at org.jruby.RubyClass.finvoke(RubyClass.java:418)
  at
org.jruby.javasupport.util.RuntimeHelpers.invoke(RuntimeHelpers.java:339)
  at org.jruby.RubyObject.callMethod(RubyObject.java:692)
...

Here is the marshal_dump method, which is based on the one in
RubyComplex:

    @JRubyMethod(name = "marshal_dump")
    public IRubyObject marshal_dump(ThreadContext context) {
        System.err.println("marshal_dump; returning to_s = " + to_s());
// DEBUG
        return to_s();
    }

I don't understand what is throwing the ClassCastException. Does
anybody have any ideas?

Jim
--
Jim Menard, jimm@io.com, jim.menard@gmail.com
http://www.io.com/~jimm/

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

    http://xircles.codehaus.org/manage_email
F8101d1b395ef58feb1d5c99bf9356df?d=identicon&s=25 Jim Menard (Guest)
on 2008-11-21 14:40
(Received via mailing list)
I have worked around this by defining marshal_dump and marshal_load in
Ruby instead of Java. I don't know why it works in Ruby but throws a
ClassCastException if define in Java.

On Thu, Nov 20, 2008 at 4:20 PM, Jim Menard <jim.menard@gmail.com>
wrote:
>
>
> Jim

--
Jim Menard, jimm@io.com, jim.menard@gmail.com
http://www.io.com/~jimm/

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

    http://xircles.codehaus.org/manage_email
This topic is locked and can not be replied to.