Created
November 15, 2014 20:12
-
-
Save akhikhl/e56d36699a0d7f6cc97c to your computer and use it in GitHub Desktop.
Serializable class in groovy script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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