Skip to content

Instantly share code, notes, and snippets.

@akhikhl
Created November 15, 2014 20:12
Show Gist options
  • Save akhikhl/e56d36699a0d7f6cc97c to your computer and use it in GitHub Desktop.
Save akhikhl/e56d36699a0d7f6cc97c to your computer and use it in GitHub Desktop.
Serializable class in groovy script
// The code below produces ClassNotFoundError. How to fix it?
import groovy.transform.ToString
@ToString
class P2ModuleSource implements Serializable {
private static final long serialVersionUID = 3526473395612776159L
List uris
P2ModuleSource(List uris) {
this.uris = uris
}
}
def x = new P2ModuleSource(['aaa', 'bbb'])
def outBytes = new ByteArrayOutputStream()
def outs = new ObjectOutputStream(outBytes)
outs.writeObject(x)
outs.close()
def bytes = outBytes.toByteArray()
def inBytes = new ByteArrayInputStream(bytes)
def ins = new ObjectInputStream(inBytes)
def y = ins.readObject()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment