Actually, the JRUBY-814 patch doesn't exactly fix this. It doesn't check for methods defined in any pure Ruby classes/modules defined above the top of the Java hierarchy: ConcreteJavaProxy, JavaProxy, Object, Kernel and Java. And I would propose that it's fine (and necessary) for Java methods to be able to override methods defined in those classes.
What the 814 patch does provide is a standard place to define Ruby methods that should never be overridden, the RESERVED_NAMES HashMap in org.jruby.javasupport.JavaClass. Right now, that list includes only one name: class. I've just added _id_ and object_id as well, so that makes three.
So, we should think about which names must be absolutely excluded. But here lies a problem, and the example in this issue goes right to it. What about a name like 'id' ? Aside from the fact that it's now deprecated in Ruby (with good reason), it's a common identifier used in many Java applications. There are many other Ruby methods that collide with common names, as a quick look at the RDoc for Object and Kernel will confirm.
As I write this, I've just added a new category to JavaClass$AssignedName: WEAKLY_RESERVED (motto "we'll be peeved, but not devastated, if you override") , and added 'id' to it. Java method and field names can override it, but aliases wont. I've also decided to break RESERVED_NAMES into separate static and instance lists, since a name like 'new' shouldn't be excluded as an instance method (but really must be as a class method).
But in the end, I think the user needs to be able to specify which Ruby names are off-limits. This functionality will be easy to implement, and there are a couple of ways it can be exposed:
1. A method on the Java module, e.g., Java.dont_even_think_about_overriding "my_word"
2. An ENV variable, e.g. ENV['JAVA_EXCLUDE'] << ';my_word'
3. ???
Thoughts?
-Bill
Should fix in 091, it's burned a few people.