From: Charles Oliver Nutter Date: 2010-11-19T15:49:58+09:00 Subject: Re: defining allocate is deprecated; use rb_define_alloc_func instead On Sat, Oct 30, 2010 at 6:07 PM, Brian Takita wrote: > Hello, I'm trying to upgrade RR to Ruby 1.9.2. > > I'm getting the following warning: > > warning: defining StrongSpecFixture.allocate is deprecated; use > rb_define_alloc_func() > > Is there a way to redefine allocate in Ruby in a way that works across > all of the different Ruby implementations (JRuby, Rubinius, etc)? Not really. Most impls, including MRI and JRuby, don't actually dispatch to allocate when constructing a new object, so there's no way to replace it at runtime. This is done partially for performance reasons, and partially (at least in JRuby's case) because allocate initializes impossible-to-initialize-any-other-way internal state for the object, so replacing it would be a bad thing. JRuby 1.6 does provide a solid start on a compatible C API, though, so if it's native-level allocate binding you need, that's an option. And of course there's impl-specific ways to do this entirely from Ruby code in JRuby and probably others. - Charlie