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

XStream cannot loadXML from GroovyScriptEngine created classes

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0-JSR-6
    • Fix Version/s: 1.5.5, 1.6-beta-1
    • Component/s: groovy-jdk
    • Labels:
      None
    • Environment:
      Windows XP
    • Flags:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: