title: Can GroovyShell binding pass a reference to object when doing setVariable?
body: <p>I'm wondering if there's a way for Binding object to store reference to an object, instead of copying one?</p>
  
  <pre><code>Binding b = new Binding()
  String test = "test"
  b.setVariable("sth", test)
  test = "blah"
  GroovyShell gs = new GroovyShell(b)
  gs.evaluate("print(sth)")
  </code></pre>
  
  <p>Unfortunately it prints "test".</p>
  
  <p>Is there a way to do it in groovy?</p>
  
  <p>EDIT:</p>
  
  <p>the example I gave was wrong and way too simple.</p>
  
  <p>I think my problem occurs because I instantiate object in one thread and run the script in another.</p>
  
  <pre><code>class Test {
  
  
  [...] // field declarations
  
      public Test(String name, String url, def params, String validateScript, String afterTestScript, GroovyShell shell) {
  
  [...] //just assigning params to fields
  
          shell.setVariable("current", this)
      }
  
  
      void action() {
  
  
         response = "something"
  
      }
  
      void validate() {
          //shell.setVariable("current", this)
      }
  
      void afterTest() {
          if (afterTestScript) shell.evaluate(afterTestScript)
      }
  
  }
  </code></pre>
  
  <p>So the Test object is created in one Thread, and then I pass it as a reference to a Runnable object, which then calls <code>action</code>, <code>validate</code> and <code>afterTest</code> methods.
  If I comment out the call to <code>setVariable</code> in constructor and uncomment the call in <code>validate</code> it will work fine.</p>
  
  <p>Is it possible it's a concurrency 'issue'?
  In the afterTestScript I just want to print the response string.</p>