From: David Masover Date: 2011-06-10T17:34:24+09:00 Subject: Re: CORE - Literal Instantiation breaks Object Model On Thursday, June 09, 2011 05:30:43 PM Yukihiro Matsumoto wrote: > |The questions are: > | > |b) Is there any way to track (intercept) the instantiation of objects > |(especially those instantiated from literals) > | > | 1) without a C-level extension > | 2) with a C-level extension > > If you don't care about performance, you can investigate > ObjectSpace#each_object. Note that JRuby turns off the method by > default for performance reason. If you care about performance, I am > afraid that you have to modify the interpreter itself. Even this has limitations. A few things that aren't in ObjectSpace: Fixnum (but note, Bignum _is_ there) Symbol TrueClass FalseClass NilClass That's just off the top of my head. But I guess that's the best we can do when entirely guessing at Ilias' actual goal -- as we must do every time he posts. The best we have is: > Ability to track instantiation of every object within the system. If he wants to track instantiation for performance reasons -- for example, to see how many objects he's using at a given moment -- then ObjectSpace might work, just slowly. If there's some reason he wants to know when a Fixnum is "created", then ObjectSpace isn't sufficient, and I imagine a C extension is the least that's required.