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

Can't set the vaule of an attribute on a superclass

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-JSR-3
    • 1.0-JSR-4
    • None
    • None

    Description

      public class Test {
      public String x = "hello";

      public static void main(String[] args) {
      final Test t1 = new Test();
      final Test t2 = new Test() {}; // subclass of Test

      InvokerHelper.getMetaClass(t1).setAttribute(t1, "x", "a");
      InvokerHelper.getMetaClass(t2).setAttribute(t2, "x", "a");
      }
      }

      produces:
      Exception in thread "main" groovy.lang.MissingFieldException: No such field: x for class: Test$1
      at groovy.lang.MetaClass.setAttribute(MetaClass.java:1138)
      at Test.main(Test.java:35)

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            tug John Wilson
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: