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

MetaClass.getAttribute() doesn't work if the field is 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).getAttribute(t1, "x");
      InvokerHelper.getMetaClass(t2).getAttribute(t2, "x");
      }
      }

      The first call of getAttribute works the sewcond fails with:
      Exception in thread "main" groovy.lang.MissingFieldException: No such field: x for class: Test$1
      at groovy.lang.MetaClass.getAttribute(MetaClass.java:1112)
      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: