-
-
Notifications
You must be signed in to change notification settings - Fork 943
Closed
Milestone
Description
I'm noticing that when you change method visibility on JRuby, it has a side effect that's not present on MRI: it changes what Method#owner returns.
First, here's the behavior on MRI 2.2:
➜ ~ ruby -v
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin12.0]
➜ ~ ruby -e "class A; private_class_method :new; end; puts A.method(:new).owner"
Class
➜ ~ ruby -e "class A; private :inspect; end; puts A.instance_method(:inspect).owner"
Kernel
It looks like this has always been MRI's behavior; on 1.8.7 I see the same thing:
➜ ~ ruby -v
ruby 1.8.7 (2013-12-22 patchlevel 375) [i686-darwin12.5.0]
➜ ~ ruby -e "class A; private_class_method :new; end; puts A.method(:new).owner"
Class
➜ ~ ruby -e "class A; private :inspect; end; puts A.instance_method(:inspect).owner"
Kernel
Compare that to JRuby's behavior:
➜ ~ ruby -v
jruby 1.7.8 (1.9.3p392) 2013-11-14 0ce429e on Java HotSpot(TM) 64-Bit Server VM 1.6.0_65-b14-462-11M4609 [darwin-x86_64]
➜ ~ ruby -e "class A; private_class_method :new; end; puts A.method(:new).owner"
#<Class:A>
➜ ~ ruby -e "class A; private :inspect; end; puts A.instance_method(:inspect).owner"
A
Metadata
Metadata
Assignees
Labels
No labels