Issue Type: Bug Bug
Affects Versions: JRuby 1.6.7
Assignee: Unassigned
Components: Ruby 1.8.7
Created: 18/Jan/13 4:57 PM
Description:

In a JRuby script when running a script within a container the containers classpath is leaked to the main script. I will illustrate with irb.

At the start of irb we can see my irb knows nothing of Foo...

 
irb(main):001:0> Foo.sayFoo
NameError: uninitialized constant Foo
        from org/jruby/RubyModule.java:2642:in `const_missing'

Let us set up a scripting container...

 
irb(main):002:0> require 'java'
=> true
irb(main):003:0> require 'C:\languages\jruby-1.6.7.2\lib\jruby-complete-1.6.7.2.jar'
=> true
irb(main):004:0> java_import 'org.jruby.embed.ScriptingContainer'
=> Java::OrgJrubyEmbed::ScriptingContainer
irb(main):005:0> container = ScriptingContainer.new
=> #<Java::OrgJrubyEmbed::ScriptingContainer:0xb34646>

We will now create a script in variable a. We do not want that script to 'pollute' our irb...

 
irb(main):006:0> a =  "require 'java' ;require 'c:/temp/foo.jar'; java_import 'gov.va.Foo' ; Foo.sayFoo"
=> "require 'java' ;require 'c:/temp/foo.jar'; java_import 'gov.va.Foo' ; Foo.sayFoo"
irb(main):008:0> val = container.runScriptlet(a)
=> "Foo Foo Foo!!"

Our scriptlet worked!

But our irb knows about Foo

 
irb(main):009:0> Foo.sayFoo
=> "Foo Foo Foo!!"
Environment: Windows XP
Project: JRuby
Priority: Major Major
Reporter: Cris Shupp
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
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

Reply via email to