Reopening class in module : jruby and MRI differ


#1

Consider the following example :

module MyModule
class MyClass
private
def my_method
puts “A”
end
end
end

include MyModule

class MyClass
public :my_method
end

MyClass.new.my_method

This works both in ruby-1.8.6 and ruby-1.9.1.
Jruby gives “undefined method ‘my_method’ for class ‘MyClass’
(NameError)”.
I feel that jruby is somehow “right” and MRI “wrong”, but …


#2

Michel D. wrote:

Consider the following example :

Better an clearer example :

module MyModule
class MyClass
def self.my_method
puts “old”
end
end
end

include MyModule

class MyClass
def self.my_method
puts “new”
end
end

MyClass.my_method
::MyModule::MyClass.my_method

MRI says :
new
new

jruby says
new
old

Feature ? Bug ?