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

XStream cannot loadXML from GroovyScriptEngine created classes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.0-JSR-6
    • 1.5.5, 1.6-beta-1
    • groovy-jdk
    • None
    • Windows XP
    • Patch

    Description

      GroovyScriptEngine does not expose it's ClassLoader and therefore objects created and serialized using the GSE cannot be read back in.

      eg.
      ...

      Class objectClass = new GroovyScriptEngine().getClassByName(path);
      Object obj = objectClass.newInstance();

      XStream xstream = new XStream();
      FileOutputStream out = new FileOutputStream(new File("myobj.xml"));
      xstream.toXML(obj, out);
      ...
      // input stream defs removed
      obj = xstream.fromXML(xmlIn);

      ... causes com.thoughtworks.xstream.alias.CannotResolveClassException:, even if you set new GroovyClassLoader() as xstream's classloader it still cannot resolve the class.

      Exposing the ClassLoader would enable this. Attached is a GSE that allows this.

      Attachments

        1. GroovyScriptEngine.java
          14 kB
          Matthew Corby-Eaglen

        Activity

          People

            paulk Paul King
            matt.corby Matthew Corby-Eaglen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: