serialization - How to serialize groovys LazyMap in Java -


i use distributed java application groovy scripting support. when comes serialization notserializableexception groovys lazymap. checked source code of lazymap , not seem preventing serialization. how can use java serialization on such objects? should byte code manipulate or there easier way? since talking distributed applications 1 can assume talking huge amount of data , therefore want avoid recursively copy laymap one.

i wrap possible groovy objects wrapper class , use kryo inside of class, seems work quite (at least prototype).

public class wrapper implements serializable {     private static final long serialversionuid = 889826451319869803l;     private transient object wrapped;      public wrapper() {      }      public wrapper(object wrapped) {         this.wrapped = wrapped;     }      private void writeobject(java.io.objectoutputstream stream) throws ioexception {         kryo kryo = new kryo();         bytearrayoutputstream bos = new bytearrayoutputstream();         output output = new output(bos);         kryo.writeobject(output, wrapped);         output.close();         stream.writeobject(bos.tobytearray());     }      private void readobject(java.io.objectinputstream stream) throws ioexception, classnotfoundexception {         kryo kryo = new kryo();         byte[] bytes = (byte[]) stream.readobject();         bytearrayinputstream bis = new byteinputstream(bytes, bytes.length);         input input = new input(bis);         wrapped = kryo.readobject(input, lazymap.class);         input.close();     } } 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -