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

Static properties are not overriden correctly in the byte code

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Cannot Reproduce
    • 1.5, 1.5.1
    • 1.5.2
    • bytecode
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: