Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

JRuby behaves different from MRI and Rubinius when it comes to setting Module#name #497

Closed
rkh opened this Issue · 4 comments

3 participants

Konstantin Haase Hiro Asari Charles Oliver Nutter
Hiro Asari
Owner

The problem appears to manifest when a class inherits from Module, and presumably we are not looking up the string representations correctly.

class A < Module; end; A.new.to_s # => "#<Module:0x6beebab1>" in JRuby, "#<A:0x007f94621be538>" in MRI

In the case above, A.new returns an A object in both cases.

Charles Oliver Nutter
Owner

I think I might see the problem here. When the A class is defined, it does get its name (RubyModule.baseName) set properly. However, by the time we reach the to_s, the metaclass for the A instance appears to be a new singleton class. As a result, it ends up following logic for building a singleton class name, which gives us the Module version instead of the A version.

This could either be a problem with how we calculate the singleton name for a module subclass, or potentially as simple as Module.new (getting called for A.new) always creating a new anonymous module.

Konstantin Haase
rkh commented

Note: In my opinion this is not a big issue. Just thought I should let you know.

Charles Oliver Nutter
Owner

I think I have a fix...and yeah, not a big issue. Not looking to land any big issues right before release :-)

Charles Oliver Nutter headius closed this in 6480caa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.