Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: JRuby 1.5.6
-
Fix Version/s: None
-
Component/s: Interpreter
-
Labels:None
-
Environment:Mac OSX 10.6.5
-
Number of attachments :
Description
If I create a module and extend it in an object, creating singleton_methods, I should be able to hide one of the object's singleton methods by making it private. This works in MRI Ruby 1.8.7, Ruby 1.9.1, and many of the derivatives (I've also tried it in MacRuby 0.8, and REE 1.8.7).
The following code behaves differently in MRI and JRuby 1.5.6
- simple module
module Xmod
def amethod
end
end
- create an object with singleton methods by extending Xmod
x = Object.new
x.extend Xmod
p x.singleton_methods # ["amethod"] # we're all good here
- change the singleton method to private
class << x
private :amethod
end - shouldn't see private method any more, but JRuby still shows it
p x.singleton_methods # MRI => [], JRuby 1.5.6 => ["amethod"]
Note, I tried to simplify the test by just trying:
y = Object.new
class << y
def another_method
end
private :another_method
end
p y.singleton_methods
But this test case works. The bug only shows up with a singleton method created by an extend.