Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-2490

Static properties are not overriden correctly in the byte code

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.5, 1.5.1
    • Fix Version/s: 1.5.2
    • Component/s: bytecode
    • Labels:
      None

      Description

      If you have two java classes like this:

      public class One {
      
          static String foo = "hello";
      }
      public class Two extends One{
      
          static String foo = "goodbye";
      }
      

      And you write a test like this:

      public class StaticOverrideTest extends TestCase {
      
          public void testOne() {
              System.out.println("One.foo = " + One.foo);
              System.out.println("Two.foo = " + Two.foo);
          }
      }
      

      It prints

      "hello"
      "goodbye"

      As expected. Do the same thing with two Groovy classes

      class One { static foo = "hello" }
      class Two extends One { static foo = "goodbye" }
      
      println One.foo
      println Two.foo
      

      It prints

      "hello"
      "hello"

      The problem appears to be at the byte code level

        Attachments

          Activity

            People

            • Assignee:
              ait Alex Tkachman
              Reporter:
              graemerocher Graeme Rocher
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: