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

Closed
rkh opened this Issue Jan 14, 2013 · 4 comments

3 participants

@BanzaiMan
JRuby Team member

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.

@headius
JRuby Team member

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.

@rkh
rkh commented May 9, 2013

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

@headius
JRuby Team member

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

@headius headius closed this in 6480caa May 10, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment