Groovy
  1. Groovy
  2. GROOVY-4386

static import does not work in Groovy 1.7.4

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.7.4
    • Fix Version/s: 1.7.6, 1.8-beta-3
    • Component/s: None
    • Labels:
      None
    • Environment:
      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.

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

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Paul King
            Reporter:
            Frode Stokke
          • Votes:
            15 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development