Kernel.load with wrap=true does not protect the global namespace of calling
program
-----------------------------------------------------------------------------------
Key: JRUBY-4339
URL: http://jira.codehaus.org/browse/JRUBY-4339
Project: JRuby
Issue Type: Bug
Components: Core Classes/Modules, RubySpec
Affects Versions: JRuby 1.4
Reporter: Vladimir Sizikov
Attachments: load_t.rb, load_test.rb
The rubydoc for Kernel#load explicitly states about the wrap parameter:
"If the optional wrap parameter is true, the loaded script will be executed
under an anonymous module, protecting the calling program's global namespace."
But JRuby doesn't provide such protection at the moment.
This caused one rubyspec failure:
{noformat}
1)
Kernel#load allows wrapping the code in the file in an anonymous module FAILED
Expected "constant"
to equal nil
/opt/work/rubyspec.git/core/kernel/load_spec.rb:233
/opt/work/rubyspec.git/core/kernel/load_spec.rb:31
/opt/work/rubyspec.git/core/kernel/load_spec.rb:55:in `load'
/opt/work/mspec.git/bin/mspec-run:8
Finished in 0.461000 seconds
{noformat}
Attached also a standalone example that exhibits the problem. Run load_test.rb
and you'll see:
Z:\work\samples>ruby load_test.rb
"main -- 31095610"
"MAIN: main -- 31128780"
nil
nil
Z:\work\samples>jruby load_test.rb
"main -- 18788761"
"MAIN: main -- 9102426"
"constant"
"constant"
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email