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

Changes to metaclasses should not leak into subsequent script executions

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.3.2
    • 4.x
    • None
    • None

    Description

      This is roughly related to GROOVY-5786.
      When executing a script in the Groovy ScriptEngine (the JSR223 one) and that script makes changes to the metaclass registry, the modification will be available to the next script.
      For example, If I execute

      String.metaClass {
        foobar ={ 
          delegate
        }
      }
      print("Hello".foobar())
      

      the script prints "Hello".
      If I execute

      print("Hello".foobar())
      

      in the same engine again, it prints "Hello" again. I think it should throw a MissingMethodException.

      Attachments

        Activity

          People

            Unassigned Unassigned
            jkemnade Jochen Kemnade
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: