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

GroovyScriptEngine.loadScriptByName returns anonymous inner classes on second invocation/reload

    XMLWordPrintableJSON

Details

    Description

      When using GroovyScriptEngine to create classes, invoking loadScriptByName twice on the same source file will return an anonymous inner classes on the second invocation (eg, reloading classes).

      class MySwingPanel extends FrameworkPanel
      {
      def initPanel()
      {
      def b = new Button('click me')
      b.addActionListener( new ActionListener()

      { // implementation code... }

      )
      }
      }

      GroovyScriptEngine gse ...
      gse.loadScriptByName('myswingpanel.groovy') // returns MySwingPanel

      // now reload everything

      gse.getGroovyClassLoader().clearCache();
      gse.loadScriptByName('myswingpanel.groovy') // returns MySwingPanel$1

      For now the workaround in my project is to just create a new instance of GroovyScriptEngine.

      http://old.nabble.com/loading-multiple-classes-with-loadScriptByName----bug-or-feature--td27252081.html

      Attachments

        Activity

          People

            roshandawrani Roshan Dawrani
            mpriatel Mark Priatel
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: