History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: JRUBY-1166
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Anders Bengtsson
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
JRuby

'public_instance_methods' different from MRI within Rake (breaking Needle)

Created: 24/Jun/07 04:00 PM   Updated: 21/Mar/08 10:37 PM
Component/s: Application Error
Affects Version/s: None
Fix Version/s: JRuby 1.1+

Time Tracking:
Not Specified

Environment: trunk@3912
Issue Links:
Related
 


 Description  « Hide
The 'public_instance_methods' method reports different results for MRI and JRuby when running within Rake. Even though they report the same ancestors of self's class, the methods differ.

In particular, methods from FileUtils are not listed in public_instance_methods from MRI but they are in JRuby.

Reproduced with this code in a Rakefile, then run with Rake 0.7.3 on both:

class << self
p ancestors
p public_instance_methods
end

MRI gives this:

[Object, RakeFileUtils, FileUtils, FileUtils::StreamUtils_, Kernel]
["methods", "instance_eval", "dup", "require_gem", "instance_variables", "instance_of?", "extend", "eql?", "taguri", "id", "hash", "singleton_methods", "include", "taguri=", "taint", "instance_variable_get", "frozen?", "kind_of?", "method", "to_a", "display", "type", "protected_methods", "public", "instance_variable_set", "is_a?", "respond_to?", "to_s", "to_yaml", "object_id", "class", "private_methods", "==", "tainted?", "require", "__id__", "===", "untaint", "nil?", "to_yaml_style", "inspect", "send", "=~", "clone", "public_methods", "private", "__send__", "freeze", "equal?", "to_yaml_properties", "gem"]

While JRuby gives this:

["public", "include", "private", "to_s", "java_kind_of?", "to_yaml_node", "file", "multitask", "taguri", "desc", "namespace", "timeout", "Rational", "to_yaml_properties", "include_class", "task", "directory", "file_create", "import", "rule", "to_yaml", "to_yaml_style", "sh", "chmod", "ln_s", "mv", "symlink", "install", "nowrite", "safe_unlink", "rm_f", "copy", "ln", "mkpath", "cp_r", "mkdir", "mkdir_p", "chdir", "move", "rmdir", "chown_R", "ln_sf", "cp", "chown", "ruby", "link", "remove", "rm", "rmtree", "chmod_R", "rm_r", "cd", "makedirs", "verbose", "touch", "when_writing", "rm_rf", "split_all", "fu_world_writable?", "safe_ln", "object_id", "frozen?", "eql?", "=~", "methods", "to_a", "tainted?", "javax", "trap", "taint", "public_methods", "dup", "method", "==", "singleton_methods", "is_a?", "instance_eval", "equal?", "instance_variable_get", "com", "instance_of?", "hash", "inspect", "java", "org", "__id__", "clone", "__send__", "id", "instance_variable_set", "send", "gem", "untaint", "class", "protected_methods", "kind_of?", "require_gem", "instance_variables", "display", "extend", "freeze", "private_methods", "nil?", "type", "===", "instance_exec", "require", "respond_to?"]

I have a problem with Needle 1.3.0 breaking because of this. In a more complex situation, it tries to call 'undef_method' on a method returned by 'public_instance_methods', but that method isn't "there", causing an error. (But it works in the simpler situation above).



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Bengtsson - 24/Jun/07 04:04 PM
Sorry, the JRuby output should be this (first line was missing above):

[Object, RakeFileUtils, FileUtils, FileUtils::StreamUtils_, Kernel]
["public", "include", "private", "to_s", "java_kind_of?", "to_yaml_node", "file", "multitask", "taguri", "desc", "namespace", "timeout", "Rational", "to_yaml_properties", "include_class", "task", "directory", "file_create", "import", "rule", "to_yaml", "to_yaml_style", "sh", "chmod", "ln_s", "mv", "symlink", "install", "nowrite", "safe_unlink", "rm_f", "copy", "ln", "mkpath", "cp_r", "mkdir", "mkdir_p", "chdir", "move", "rmdir", "chown_R", "ln_sf", "cp", "chown", "ruby", "link", "remove", "rm", "rmtree", "chmod_R", "rm_r", "cd", "makedirs", "verbose", "touch", "when_writing", "rm_rf", "split_all", "fu_world_writable?", "safe_ln", "object_id", "frozen?", "eql?", "=~", "methods", "to_a", "tainted?", "javax", "trap", "taint", "public_methods", "dup", "method", "==", "singleton_methods", "is_a?", "instance_eval", "equal?", "instance_variable_get", "com", "instance_of?", "hash", "inspect", "java", "org", "__id__", "clone", "__send__", "id", "instance_variable_set", "send", "gem", "untaint", "class", "protected_methods", "kind_of?", "require_gem", "instance_variables", "display", "extend", "freeze", "private_methods", "nil?", "type", "===", "instance_exec", "require", "respond_to?"]


Anders Bengtsson - 07/Jul/07 01:33 PM
A better reproduction of the same problem is found in JRUBY-1188.

Charles Oliver Nutter - 22/Oct/07 12:34 AM
Clean up public/private/protected instance/class methods for 1.1, using Marcin's diff script and this bug plus JRUBY-1188.

Marcin Mielzynski - 22/Oct/07 06:26 AM
There is also an issue with singleton_methods that shouldn't use isPublic to filter the resulting array.
The script needs to be modified to catch singleton method differences too.

Charles Oliver Nutter - 15/Feb/08 12:58 PM
Punting issues from 1.1 RC2 to 1.1 final.

Charles Oliver Nutter - 06/Mar/08 10:46 AM
Here's output from trunk today:
~/NetBeansProjects/jruby &#10132; ruby test_public_methods.rb 
[Object, Kernel]
["==", "===", "=~", "__id__", "__send__", "class", "clone", "display", "dup", "eql?", "equal?", "extend", "freeze", "frozen?", "hash", "id", "include", "inspect", "instance_eval", "instance_of?", "instance_variable_defined?", "instance_variable_get", "instance_variable_set", "instance_variables", "is_a?", "kind_of?", "method", "methods", "nil?", "object_id", "private", "private_methods", "protected_methods", "public", "public_methods", "respond_to?", "send", "singleton_methods", "taint", "tainted?", "to_a", "to_s", "type", "untaint"]
~/NetBeansProjects/jruby &#10132; jruby test_public_methods.rb 
[Object, Kernel]
["==", "===", "=~", "__id__", "__send__", "class", "clone", "display", "dup", "eql?", "equal?", "extend", "freeze", "frozen?", "hash", "id", "inspect", "instance_eval", "instance_exec", "instance_of?", "instance_variable_defined?", "instance_variable_get", "instance_variable_set", "instance_variables", "is_a?", "kind_of?", "method", "methods", "nil?", "object_id", "private_methods", "protected_methods", "public_methods", "respond_to?", "send", "singleton_methods", "taint", "tainted?", "to_a", "to_s", "type", "untaint"]

The differences are:

  • JRuby has extra: include, instance_exec
  • JRuby is missing: private, public

So it's much closer now. The remaining methods may be the ones added to the toplevel singleton, so we're just not filtering them out correctly?


Charles Oliver Nutter - 06/Mar/08 10:47 AM
Oops, mine wasn't running rake, so I suppose there's a number of other methods that get pulled in there. But probably the same issue?

Thomas E Enebo - 17/Mar/08 06:21 PM
Not enough time. Bumping.

Thomas E Enebo - 19/Mar/08 12:09 PM
Daniel has a smaller testcase involving a core class:
p Dir.public_instance_methods(false)
 
C:\Documents and Settings\djberge\workspace\facade>ruby test.rb
["tell", "each", "path", "pos", "close", "read", "rewind", "pos=", "seek"]
 
C:\Documents and Settings\djberge\workspace\facade>jruby test.rb
["initialize", "rewind", "each", "tell", "close", "pos", "pos=", "seek", "path", "entries", "read"]

Bill Dortch - 21/Mar/08 10:37 PM
Also:

MRI

> Math.public_methods(false)
=> ["acosh", "class_eval", "const_missing", "private_instance_methods", "tan", ">=", "<=", "log10",
"to_s", "private_class_method", "sinh", "<", "include?", "public_instance_methods", "cos", "erf",
"private_method_defined?", ">", "name", "exp", "const_get", "atan", "method_defined?", "ldexp", 
"included_modules", "class_variables", "asinh", "autoload?", "acos", "const_defined?", "sqrt",
"module_eval", "tanh", "protected_method_defined?", "erfc", "protected_instance_methods", "sin",
"log", "autoload", "ancestors", "instance_method", "const_set", "cosh", "public_class_method",
"instance_methods",  "atan2", "hypot", "public_method_defined?", "class_variable_defined?",
"atanh", "<=>", "freeze", "constants", "asin", "==", "===", "frexp"]

JRuby

> Math.public_methods(false)
=> []

Actual Math methods also don't show up in Math.methods or Math.public_methods.