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

Divergent behavior in MRI vs JRuby wrt Class::undef #2131

Closed
cheald opened this Issue Nov 6, 2014 · 1 comment

Comments

Projects
None yet
3 participants
@cheald
Copy link
Contributor

cheald commented Nov 6, 2014

Under MRI - tested 1.9.3, 2.0.0, 2.1.0, and 2.2.0-preview:

c1 = Class.new {private; def foo; end}
c2 = Class.new(c1) {public; :foo}
c1.class_eval {undef foo}
c2.foo => NoMethodError

Under JRuby:

c1 = Class.new {private def foo; end}
c2 = Class.new(c1) {public :foo}
c1.class_eval {undef foo}
c2.foo => nil

This notably breaks a test in the new stdlib, to the effect of

c1 = Class.new {private def foo; end}
c2 = Class.new(c1) {public :foo}
c3 = Class.new(c2) {def foo; end}
c1.class_eval {undef foo}
m = c3.instance_method(:foo).super_method # Expects nil, gets c2's copy of #foo.
@rtyler

This comment has been minimized.

Copy link

rtyler commented Aug 7, 2015

This is fixed in JRuby 9k at least

[27] pry(main)> c1 = Class.new {private def foo; end}
=> #<Class:0x70f59913>
[28] pry(main)> c2 = Class.new(c1) {public :foo}
=> #<Class:0x77258e59>
[29] pry(main)> c1.class_eval {undef foo}
=> nil
[30] pry(main)> c2.foo 
NoMethodError: undefined method `foo' for #<Class:0x77258e59>
from org/jruby/RubyBasicObject.java:1595:in `method_missing'
[31] pry(main)> JRUBY_VERSION
=> "9.0.0.0"
[32] pry(main)> 

@rtyler rtyler closed this Aug 7, 2015

@enebo enebo added this to the JRuby 9.0.1.0 milestone Aug 20, 2015

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.