You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because of some code that does not believe in duck typing, I need to subclass Time for testing purposes. This works fine in Ruby 2.4.2:
irb(main):001:0> class TT < Time ; def initialize(m, n) ; super(m) ; end ; end
=> :initialize
irb(main):002:0> TT.new(1, 2)
=> 0001-01-01 00:00:00 +0100
However, the same code fails in JRuby 9.1.13.0:
irb(main):004:0* class TT < Time ; def initialize(m, n) ; super(m) ; end ; end
=> :initialize
irb(main):005:0> TT.new(1, 2)
ArgumentError: wrong number of arguments (0 for 2)
from (irb):5:in `initialize'
from org/jruby/RubyTime.java:1252:in `new'
from (irb):5:in `<eval>'
from org/jruby/RubyKernel.java:994:in `eval'
from org/jruby/RubyKernel.java:1292:in `loop'
from org/jruby/RubyKernel.java:1114:in `catch'
from org/jruby/RubyKernel.java:1114:in `catch'
from .rbenv/versions/jruby-9.1.13.0/bin/irb:13:in `<main>'
Whereas providing an empty constructor works fine even in JRuby:
irb(main):001:0> class TT < Time ; def initialize ; super() ; end ; end
=> :initialize
irb(main):002:0> TT.new
=> 2018-03-30 01:07:33 +0200
Is this an obscure bug or have I misunderstood something?
Environment
jruby 9.1.13.0 (2.3.3) 2017-09-06 8e1c115 Java HotSpot(TM) 64-Bit Server VM 25.121-b13 on 1.8.0_121-b13 +jit [darwin-x86_64]
The text was updated successfully, but these errors were encountered:
Yeah this is a long-standing issue where our Time class defines its own new rather than its own initialize, and that new attempts to call initialize with zero arguments always. I've been meaning to try to fix this, so I'll have another crack at it.
@bittrance I've pushed a fix for this to the jruby-9.1 branch, which can be found in the stable nightly build. Please let us know that it works for you.
Because of some code that does not believe in duck typing, I need to subclass
Time
for testing purposes. This works fine in Ruby 2.4.2:However, the same code fails in JRuby 9.1.13.0:
Whereas providing an empty constructor works fine even in JRuby:
Is this an obscure bug or have I misunderstood something?
Environment
jruby 9.1.13.0 (2.3.3) 2017-09-06 8e1c115 Java HotSpot(TM) 64-Bit Server VM 25.121-b13 on 1.8.0_121-b13 +jit [darwin-x86_64]
The text was updated successfully, but these errors were encountered: