title: Groovy and Java static variable behaviour
body: <p>I have been doing some Java and Grails3 programming recently.
  I found some behavior that I don't understand.</p>
  
  <p>There are two groovy classes:  </p>
  
  <pre><code>class Super {
      static String desc = "Super"
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>class Sub extends Super {
      static String desc = "Sub"
  }
  </code></pre>
  
  <p>Now, I'm running following code in Java and Groovy:</p>
  
  <pre><code>Super aSuper = new Super();
  Sub sub = new Sub();
  Super superSub = new Sub();
  
  System.out.println("Super object: [" + aSuper.getDesc() + "]"); //1
  System.out.println("Sub object: [" + sub.getDesc() + "]");//2
  System.out.println("Sub object, super reference: [" + superSub.getDesc()+ "]");//3
  System.out.println("Super reference: [" + Super.getDesc()+ "]");//4
  System.out.println("Sub reference: [" + Sub.getDesc()+ "]");//5
  </code></pre>
  
  <p>Results of 1,2,4,5 are the same in both cases and easy to predict ([Super], [Sub], [Super], [Sub])</p>
  
  <p>But in case number 3 when running above code form Java class output will be: <code>Sub object, super reference: [Super]</code>
  And from Groovy it will result in: <code>Sub object, super reference: [Sub]</code></p>
  
  <p>Why is Groovy interpretation of <code>static</code> variable different?</p>