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

static import does not work in Groovy 1.7.4

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.7.4
    • 1.7.6, 1.8-beta-3
    • None
    • None
    • Windows, Groovy Version: 1.7.4 JVM: 1.6.0_21

    Description

      Static import does not work from Groovy scripts.

      Example:

      foo/Constants.groovy:

      package foo
      
      class Constants {
          static final PI = 3.14
      }
      

      foo/Test.groovy

      package foo
      import static foo.Constants.PI
      
      class Test {
          static main(args) {
              println("pi=" + PI)
          }
      }
      

      When you try to run this (without compling with groovyc first), you get:

      groovy -cp . foo\Test.groovy
      Caught: groovy.lang.MissingPropertyException: No such property: PI for class: foo.Test
              at foo.Test.main(Test.groovy:6)
      

      If you first run "groovyc foo\Constants.groovy" the above command succeeds.

      Attachments

        1. p1.patch
          1 kB
          Jochen Theodorou
        2. p2.patch
          1 kB
          Jochen Theodorou

        Activity

          People

            paulk Paul King
            frodesto Frode Stokke
            Votes:
            15 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: