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

"Class is declared in a dynamic context"

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-RC-1
    • 1.1-beta-1
    • None
    • None

    Description

      Error when trying to call the static method forName() of the class java.lang.Class. The script:

      static def blah() {
      ['Integer'].collect

      { Class.forName(it).newInstance() }
      }

      when compiled with groovyc gives:

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, bug15.groovy: 2: Class is declared in a dynamic context, but you tried to access it from a static context.
      @ line 2, column 26.
      ['Integer'].collect { Class.forName(it).newInstance() }

      ^

      If I put "java.lang." in front of Class, it complains that java is declared in a dynamic context.

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            mcspanky Martin C. Martin
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: