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

static final declarations in classes not producing getter

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-JSR-5
    • 1.0-RC-1
    • None
    • None

    Description

      When upgrading from earlier groovy builds to the new visibility/@Property handling, or when not understanding these new rules
      properly, code can fail unexpectedly - although it seems to be related to inherited access only. testInheritedStaticFinal fails.

      import groovy.util.GroovyTestCase
      
      /*
      
       Test script to examine static field/property issues in JSR 05
      
       */
      
      class TestVisibility extends GroovyTestCase
      {
          void testInheritedStaticFinal()
          {
              new B().constantAccess()
          }
      
          void testStaticFinal()
          {
              def x = A.SOMECONSTANT
          }
      
          void testInheritedPublicStaticFinal()
          {
              new D().constantAccess()
          }
      
          void testPublicStaticFinal()
          {
              def x = C.SOMECONSTANT
          }
      }
      
      class A
      {
          static final SOMECONSTANT = 0
      }
      
      class B extends A
      {
          void constantAccess()
          {
              println SOMECONSTANT
          }
      }
      
      class C
      {
          public static final SOMECONSTANT = 0
      }
      
      class D extends C
      {
          void constantAccess()
          {
              println SOMECONSTANT
          }
      }
      

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            marc@anyware.co.uk Marc Palmer
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: