Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-4683 static import collection task
  3. GROOVY-3538

failed to import static on default classes

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Closed
    • Major
    • Resolution: Information Provided
    • 1.6.2
    • None
    • Compiler
    • None
    • WindowsXP

    Description

      I see two related problems with simple static import on classes that suppose to be already be imported in namespace:

      1) This failed running from a script:
      import static Math.*; println(random())

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, D:\test.groovy: 1: unable to resolve class Math
      @ line 1, column 1.
      import static Math.*; println(random())
      ^

      1 error

      But this in a script will work:
      import static java.lang.Math.*; println(random())

      2) This failed running from a command line:
      groovy -e "import static java.lang.Math.*; println(random())"
      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, script_from_command_line: 1: unexpected token: ( @ line 1, column 22.
      1 error

      Attachments

        Activity

          People

            Unassigned Unassigned
            thebugslayer Zemian Deng
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: