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
-
Patch Submitted:Yes
-
Number of attachments :
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.
Added a getter for GroovyClassLoader. Tested with this script:
Groovy would actually let you peak inside and get the private groovyLoader variable but this minor API addition lets both Java and Groovy get the class loader.