JRuby

RubyGems 1.0.0 hack may be due to yaml_initialize not getting called

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: JRuby 1.1RC1
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    0

Description

When I installed RubyGems 1.0.0 into JRuby trunk, I had to hack version.rb to call to_ints on the target version object when performing comparisons:

  def <=>(other)
    return 1 unless other
    @ints <=> other.to_ints
  end

This is because the original code, which just called the attr accessor other.ints, was getting a nil result. The ints attr is initialized here:

  def normalize
    @ints = build_array_from_version_string

    return if @ints.length == 1

    @ints.pop while @ints.last == 0

    @ints = [0] if @ints.empty?
  end

Which is called from here on the version attr setter:

  def version=(version)
    @version = version.to_s.strip
    normalize
  end

Which is called by all initialization entry points into the object:

  def initialize(version)
    raise ArgumentError, "Malformed version number string #{version}" unless
      self.class.correct?(version)

    self.version = version
  end
...
  def marshal_load(array)
    self.version = array[0]
  end
...
  def yaml_initialize(tag, values)
    self.version = values['version']
  end

So the simplest conclusion here is that for some path to object initialization, one of these entry points is not getting invoked. I confirmed briefly that marshal_dump is getting called for unmarshaling, and initialize would be nearly impossible to avoid calling for normal object instantiation. That leaves yaml_initialize as the most likely candidate, and Ola mentioned there were issues getting yaml_initialize to work in JRuby.

I do not want to leave the hack in place; RubyGems should "just work". We need to figure out why @ints isn't getting initialized.

Issue Links

Activity

Hide
Charles Oliver Nutter added a comment -

Fixed in 5365 and 5366. to_ints hack is no longer needed.

Show
Charles Oliver Nutter added a comment - Fixed in 5365 and 5366. to_ints hack is no longer needed.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: