Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Comments

Projects
None yet
3 participants
@rkh
Copy link
Contributor

rkh commented Jan 14, 2013

@BanzaiMan

This comment has been minimized.

Copy link
Member

BanzaiMan commented Jan 16, 2013

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

This comment has been minimized.

Copy link
Member

headius commented May 9, 2013

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

This comment has been minimized.

Copy link
Contributor Author

rkh commented May 9, 2013

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

@headius

This comment has been minimized.

Copy link
Member

headius commented May 10, 2013

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
You can’t perform that action at this time.