Forum: JRuby 1.1.6 BigDecimal mystery: "AssertionError: NULL Metaclass!!?!?!-"

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.
Jim M. (Guest)
on 2008-12-19 22:00
(Received via mailing list)
This code:

  wrapper = new RubyBigDecimal(runtime, (BigDecimal)obj);

produces this error in 1.1.6 but not 1.1.4:

-java.lang.AssertionError: NULL Metaclass!!?!?!-
  org.jruby.RubyBasicObject.<init>(RubyBasicObject.java:193)
  org.jruby.RubyObject.<init>(RubyObject.java:95)
  org.jruby.RubyNumeric.<init>(RubyNumeric.java:100)
  org.jruby.RubyBigDecimal.<init>(RubyBigDecimal.java:142)
  ed.lang.ruby.RubyObjectWrapper.toRuby(RubyObjectWrapper.java:115)
...

What am I doing wrong?

Jim
--
Jim M., removed_email_address@domain.invalid, 
removed_email_address@domain.invalid
http://www.io.com/~jimm/

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

    http://xircles.codehaus.org/manage_email
Jim M. (Guest)
on 2008-12-19 22:25
(Received via mailing list)
On Fri, Dec 19, 2008 at 3:00 PM, Jim M. <removed_email_address@domain.invalid>
wrote:
>  org.jruby.RubyBigDecimal.<init>(RubyBigDecimal.java:142)
>  ed.lang.ruby.RubyObjectWrapper.toRuby(RubyObjectWrapper.java:115)
> ...
>
> What am I doing wrong?

I was not loading the bigdecimal library in my Java code. To lazily
load it when needed, I created the following static method:

    /**
     * Creates a RubyBigDecimal from a Java BigDecimal. Lazily loads the
Ruby
     * BigDecimal class when first needed.
     */
    public static RubyBigDecimal javaBigDecimalToRubyBigDecimal(Ruby
runtime, BigDecimal bd) {
        if (runtime.fastGetClass("BigDecimal") == null) // lazily load
            runtime.getLoadService().require("bigdecimal");
        return new RubyBigDecimal(runtime, bd);
    }

Jim
--
Jim M., removed_email_address@domain.invalid, 
removed_email_address@domain.invalid
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.