title: without resolveStrategy=DELEGATE_FIRST properties end up as binding variables
body: <p>I'm trying to write java beans that can be loaded from a Groovy config file. The config format expects properties in closures and if I don't call <code>c.setResolveStrategy(Closure.DELEGATE_FIRST)</code> then all properties set inside the closures end up as binding variables. My program outputs:</p>
  <pre><code>In closure
  confpojo.myTestProp: null
  binding.myTestProp: true
  confpojo.app.myOther.myTestSubProp: null
  binding.myTestSubProp: true
  </code></pre>
  <p>In this answer <a href="https://stackoverflow.com/a/10761284/447503">https://stackoverflow.com/a/10761284/447503</a> they don't change the default resolveStrategy and it seems to work. What's the difference? <code>configaaa.groovy</code>:</p>
  <pre><code>    app {
          println 'In closure'
      
          myTestProp = true
      
          myOther {
              myTestSubProp = true
          }
      }
  </code></pre>
  <p>_</p>
  <pre><code>public abstract class AaaTestGroovyConfig extends Script {
  
      public static class App {
  
          public void myOther(final Closure c) {
              c.setDelegate(myOther);
              // c.setResolveStrategy(Closure.DELEGATE_FIRST);
              c.call();
          }
  
          private Boolean myTestProp;
  
          private final Other myOther = new Other();
  
          public Boolean getMyTestProp() {
              return myTestProp;
          }
  
          public void setMyTestProp(final Boolean active) {
              this.myTestProp = active;
          }
  
      }
  
      public void app(final Closure c) {
          c.setDelegate(app);
          // c.setResolveStrategy(Closure.DELEGATE_FIRST);
          c.call();
      }
  
      private App app = new App();
      public static void main(final String[] args) throws Exception {
          final CompilerConfiguration cc = new CompilerConfiguration();
          cc.setScriptBaseClass(AaaTestGroovyConfig.class.getName());
          // final ClassLoader cl = AaaTestGroovyConfig.class.getClassLoader();
          final Binding binding = new Binding();
          final GroovyShell shell = new GroovyShell(binding, cc);
          final Script script = shell.parse(new File(&quot;configaaa.groovy&quot;));
          final AaaTestGroovyConfig confpojo = (AaaTestGroovyConfig) script;
          // ((DelegatingScript) script).setDelegate(confpojo);
          script.run();
  
          System.out.println(&quot;confpojo.myTestProp: &quot; + confpojo.app.myTestProp);
          printBindingVar(binding, &quot;myTestProp&quot;);
  
          System.out
              .println(&quot;confpojo.app.myOther.myTestSubProp: &quot; + confpojo.app.myOther.myTestSubProp);
          printBindingVar(binding, &quot;myTestSubProp&quot;);
  
      }
  
      private static void printBindingVar(final Binding binding, final String name) {
          System.out
              .println(
                  &quot;binding.&quot; + name + &quot;: &quot; + (binding.hasVariable(name)
                      ? binding.getVariable(name)
                      : &quot;&quot;));
      }
  
      public static class Other {
  
          private Boolean myTestSubProp;
  
          public Boolean getMyTestSubProp() {
              return myTestSubProp;
          }
  
          public void setMyTestSubProp(final Boolean myTestSubProp) {
              this.myTestSubProp = myTestSubProp;
          }
      }
  
      public App getApp() {
          return app;
      }
  
      public void setApp(final App app) {
          this.app = app;
      }
  
  
  }
  </code></pre>