Hi.

The initialize_copy-error comes from Time#dup not working correctly. My
quickie-fix solves that. (add a dup-method with more or less the same
contents as RubyString)... as Thomas pointed out, this is not really so
great, since there are stuff that solution disregards, but it works for now.

/O

----- Original Message -----
From: Charles O Nutter <[EMAIL PROTECTED]>
Date: Saturday, March 25, 2006 7:34 am
Subject: Re: [Jruby-devel] Bug 1121928 Patch
To: [email protected]

> FIXED! RubyGlobals was passing null in to newHash for 
> defaultValue...whichis bad! I fixed that instance and added an 
> assertion in newHash to prevent
> it in the future.
> 
> I can now run RubyGems up to the same initialize_copy error, which 
> I'll dig
> into next...I suspect it's not going to be terribly pretty, since 
> nothing'sbeen using initialize_copy heavily in the past and I don't 
> think our
> semantics are right.
> 
> Committed on both HEAD and cnutter_work1.
> 
> On 3/24/06, Charles O Nutter <[EMAIL PROTECTED]> wrote:
> >
> > The new Hash#default patch appears to be broken:
> >
> > puts ENV('BOGUS')
> >
> > .. blows up with an NPE. I think it has to do with calling 
> default via
> > RubyObject.callMethod...there's a null coming back from there, 
> methinks.> I'll see what I can find.
> >
> >
> > On 3/24/06, Thomas E Enebo <[EMAIL PROTECTED]> wrote:
> > >
> > >   I sooo bungled the explanation in that bug that I must 
> apologize in
> > > the first sentence. :)
> > >
> > >   Your patch fixed some problems, but not the one represented 
> by my
> > > ether-
> > > sniffing-induced code sample in the bug report.  What I meant 
> to put
> > > in that bug was something along the lines of:
> > >
> > > h = Hash.new
> > >
> > > class << h
> > > def default(k); 2; end
> > > end
> > >
> > > p h[12]   => 2
> > >
> > >   I committed a different patch which I thinks solves 
> everything.  I
> > > also added a few extra tests too.  Give a gander.
> > >
> > >   I promise to make better bug reports in the future and I at 
> least hope
> > > the making of your patch helped to learn a little more about inner
> > > workings of JRuby's implementation.
> > >
> > > -Tom
> > >
> > > PS- All explicit method calls (callMethod("foo", args)) to a 
> ruby method
> > > should pass IRubyObject.NULL_ARRAY as an argument.  We want to 
> eliminate> > the
> > > need to null check the args list by always passing in am empty 
> array.> > I thought we would assert when this happens, but I guess 
> not.> >
> > > On Thu, 23 Mar 2006, Marc Hadley defenestrated me:
> > >
> > > > Here's a patch to solve bug 1121928. With this patch 
> Hash#default now
> > > > respects any block you set for the default and supports code 
> like:> > >
> > > > h = Hash.new {|h,k| h[k] = k.to_i*10}
> > > > puts h[2] # => 20
> > > > puts h.default # => 0
> > > > puts h.default(2) # => 20
> > > >
> > > > Note that I also had to modify HashMetaClass so Hash#default can
> > > > accept an argument. I also added a couple of unit tests to test/
> > > > testHash.rb and made sure there were no regressions.
> > > >
> > > > Marc.
> > > >
> > > > 
> ===================================================================> >
> RCS file: /cvsroot/jruby/jruby/src/org/jruby/RubyHash.java,v
> > > > retrieving revision 1.30
> > > > diff -r1.30 RubyHash.java
> > > > 89,90c89,100
> > > > <     public IRubyObject getDefaultValue() {
> > > > <         return (defaultValue == null) ? 
> getRuntime().getNil() :
> > > > defaultValue;
> > > > ---
> > > > >     public IRubyObject getDefaultValue(IRubyObject[] args) {
> > > > >         if (args!=null && args.length>1)
> > > > >             throw getRuntime().newArgumentError( 
> args.length, 1);
> > > > >
> > > > >         IRubyObject key = (args==null || args.length==0) ?
> > > > getRuntime().getNil() : args[0];
> > > > >
> > > > >         if (!defaultProc.isNil()) {
> > > > >             IRubyObject[] procargs = {this, key};
> > > > >             return ((RubyProc) defaultProc).call(procargs, 
> this);> > > >         }
> > > > >         else
> > > > >             return (defaultValue == null) ? 
> getRuntime().getNil> > > () : defaultValue;
> > > > 234c244
> > > > <               RubyHash result = newHash(getRuntime(), 
> getValueMap> > > (), getDefaultValue());
> > > > ---
> > > > >               RubyHash result = newHash(getRuntime(), 
> getValueMap> > > (), getDefaultValue(null));
> > > > 276,281c286,287
> > > > <         if (!defaultProc.isNil()) {
> > > > <               IRubyObject[] args = {this, key};
> > > > <               return ((RubyProc) defaultProc).call(args, 
> this);> > > <         }
> > > > <
> > > > <         return getDefaultValue();
> > > > ---
> > > > >         IRubyObject[] args = {key};
> > > > >         return getDefaultValue(args);
> > > > 414c420,421
> > > > <               return getDefaultValue();
> > > > ---
> > > > >                 IRubyObject[] args = {key};
> > > > >               return getDefaultValue(args);
> > > >
> > > > 
> ===================================================================> >
> RCS file: /cvsroot/jruby/jruby/src/org/jruby/runtime/builtin/meta/
> > > > HashMetaClass.java,v
> > > > retrieving revision 1.7
> > > > diff -r1.7 HashMetaClass.java
> > > > 36c36
> > > > <                       defineMethod("default", 
> Arity.noArguments(),> > > "getDefaultValue");
> > > > ---
> > > > >                       defineMethod("default", 
> Arity.optional(),> > > "getDefaultValue");
> > > >
> > > > 
> ===================================================================> >
> RCS file: /cvsroot/jruby/jruby/test/testHash.rb,v
> > > > retrieving revision 1.8
> > > > diff -r1.8 testHash.rb
> > > > 39c39
> > > > < h = Hash.new {|h,k| h[k] = 10000 }
> > > > ---
> > > > > h = Hash.new {|h,k| h[k] = k.to_i*10 }
> > > > 41c41,43
> > > > < test_equal(10000, h[10])
> > > > ---
> > > > > test_equal(100, h[10])
> > > > > test_equal(0, h.default)
> > > > > test_equal(20, h.default(2))
> > > > 44d45
> > > > <
> > > >
> > > >
> > > > ---
> > > > Marc Hadley <marc.hadley at sun.com>
> > > >
> > > >
> > > >
> > > >
> > > > -------------------------------------------------------
> > > > This SF.Net email is sponsored by xPML, a groundbreaking 
> scripting> > language
> > > > that extends applications into web and mobile media. Attend 
> the live
> > > webcast
> > > > and join the prime developer group breaking into this new coding
> > > territory!
> > > >
> > > http://sel.as-
> us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642> > > 
> _______________________________________________> > > Jruby-devel 
> mailing list
> > > > [email protected]
> > > > https://lists.sourceforge.net/lists/listinfo/jruby-devel
> > >
> > > --
> > > + http://www.tc.umn.edu/~enebo <http://www.tc.umn.edu/%7Eenebo> 
> +----
> > > mailto:[EMAIL PROTECTED] ----+
> > > | Thomas E Enebo, Protagonist  | "Luck favors the prepared    |
> > > |                              |  mind." -Louis Pasteur       |
> > >
> > >
> > > -------------------------------------------------------
> > > This SF.Net email is sponsored by xPML, a groundbreaking scripting
> > > language
> > > that extends applications into web and mobile media. Attend the 
> live> > webcast
> > > and join the prime developer group breaking into this new coding
> > > territory!
> > > http://sel.as-
> us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642> > 
> _______________________________________________> > Jruby-devel 
> mailing list
> > > [email protected]
> > > https://lists.sourceforge.net/lists/listinfo/jruby-devel
> > >
> >
> >
> >
> > --
> > Charles Oliver Nutter @ headius.blogspot.com
> > JRuby Developer @ jruby.sourceforge.net
> > Application Architect @ www.ventera.com
> >
> 
> 
> 
> --
> Charles Oliver Nutter @ headius.blogspot.com
> JRuby Developer @ jruby.sourceforge.net
> Application Architect @ www.ventera.com
> 


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Jruby-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jruby-devel

Reply via email to