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

Subclasses cannot access inhierited static fields from implicit class context

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.0-beta-10
    • class generator
    • None
    • Current (as of 3/19/04) CVS.

    Description

      Groovy subclasses of Java classses generate exception when trying to access (public) static fields from Java superclasses.

      Test Code:

      [BaseClass.java]

      public class BaseClass {
      public final static int TEST_INT = 1;
      }

      [TestSubClassCall.groovy]

      class TestSubClassCall {
      void run()

      { s = new SubClass() s.doIt() }

      static void main(args)

      { (new TestSubClassCall()).run() }

      }

      class SubClass extends BaseClass {
      static TEST_SUB_INT
      public void doIt()

      { println "Works:" x1 = BaseClass.TEST_INT println "Also Works:" x2 = TEST_SUB_INT println "Fails:" x3 = TEST_INT println "Also Fails:" x4 = this.TEST_INT }

      }

      [Output]

      Works:
      Also Works:
      Fails:
      groovy.lang.MissingPropertyException: No such property: TEST_INT for class: exp.SubClass
      at groovy.lang.MetaClass.getProperty(MetaClass.java:496)
      at gjdk.groovy.lang.MetaClass_GroovyReflector.invoke(MetaClass_GroovyReflector.java)
      at groovy.lang.MetaMethod.invoke(MetaMethod.java:108)
      at groovy.lang.MetaClass.doMethodInvoke(MetaClass.java:873)
      at groovy.lang.MetaClass.invokeMethod(MetaClass.java:268)
      at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:130)
      at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:103)
      at exp.SubClass.getProperty(TestSubclassCall.groovy)
      at org.codehaus.groovy.runtime.Invoker.getProperty(Invoker.java:509)
      at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:162)
      at exp.SubClass.doIt(TestSubclassCall.groovy:26)
      at gjdk.exp.SubClass_GroovyReflector.invoke(SubClass_GroovyReflector.java)
      at groovy.lang.MetaMethod.invoke(MetaMethod.java:108)
      at groovy.lang.MetaClass.doMethodInvoke(MetaClass.java:873)
      at groovy.lang.MetaClass.invokeMethod(MetaClass.java:268)
      at gjdk.groovy.lang.MetaClass_GroovyReflector.invoke(MetaClass_GroovyReflector.java)
      at groovy.lang.MetaMethod.invoke(MetaMethod.java:108)
      at groovy.lang.MetaClass.doMethodInvoke(MetaClass.java:873)
      at groovy.lang.MetaClass.invokeMethod(MetaClass.java:268)
      at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:130)
      at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:103)
      at exp.SubClass.invokeMethod(TestSubclassCall.groovy)
      at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:117)
      at org.codehaus.groovy.runtime.InvokerHelper.invokeNoArgumentsMethod(InvokerHelper.java:99)
      at exp.TestSubClassCall.run(TestSubclassCall.groovy:8)
      at gjdk.exp.TestSubClassCall_GroovyReflector.invoke(TestSubClassCall_GroovyReflector.java)
      at groovy.lang.MetaMethod.invoke(MetaMethod.java:108)
      at groovy.lang.MetaClass.doMethodInvoke(MetaClass.java:873)
      at groovy.lang.MetaClass.invokeMethod(MetaClass.java:268)
      at gjdk.groovy.lang.MetaClass_GroovyReflector.invoke(MetaClass_GroovyReflector.java)
      at groovy.lang.MetaMethod.invoke(MetaMethod.java:108)
      at groovy.lang.MetaClass.doMethodInvoke(MetaClass.java:873)
      at groovy.lang.MetaClass.invokeMethod(MetaClass.java:268)
      at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:130)
      at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:103)
      at exp.TestSubClassCall.invokeMethod(TestSubclassCall.groovy)
      at RunGroovy.run(RunGroovy.java:55)
      at RunGroovy.main(RunGroovy.java:60)

      Attachments

        Activity

          People

            jstrachan James Strachan
            milesparker milesparker
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: