public class KryoKt
Modifier and Type | Method and Description |
---|---|
static WireTransaction |
SerializedBytesWireTransaction(SerializedBytes<net.corda.core.transactions.WireTransaction> $receiver,
com.esotericsoftware.kryo.Kryo kryo) |
static com.esotericsoftware.kryo.Kryo |
createKryo(com.esotericsoftware.kryo.Kryo k) |
static <T> T |
deserialize(byte[] $receiver,
com.esotericsoftware.kryo.Kryo kryo) |
static <T> T |
deserialize(OpaqueBytes $receiver,
com.esotericsoftware.kryo.Kryo kryo) |
static <T> T |
deserialize(SerializedBytes<T> $receiver,
com.esotericsoftware.kryo.Kryo kryo) |
static com.esotericsoftware.kryo.Kryo |
extendKryoHash(com.esotericsoftware.kryo.Kryo kryo) |
static java.lang.String |
getATTACHMENT_STORAGE() |
static AttachmentStorage |
getAttachmentStorage(com.esotericsoftware.kryo.Kryo $receiver) |
static java.lang.ThreadLocal<com.esotericsoftware.kryo.Kryo> |
getTHREAD_LOCAL_KRYO()
Serialization utilities, using the Kryo framework with a custom serialiser for immutable data classes and a dead
simple, totally non-extensible binary (sub)format.
|
static byte[] |
readBytesWithLength(com.esotericsoftware.kryo.io.Input $receiver) |
static <T> com.esotericsoftware.kryo.Registration |
register(com.esotericsoftware.kryo.Kryo $receiver,
kotlin.reflect.KClass<T> type,
kotlin.jvm.functions.Function2<? super com.esotericsoftware.kryo.Kryo,? super com.esotericsoftware.kryo.io.Input,? extends T> read,
kotlin.jvm.functions.Function3<? super com.esotericsoftware.kryo.Kryo,? super com.esotericsoftware.kryo.io.Output,? super T,kotlin.Unit> write) |
static <T> SerializedBytes<T> |
serialize(T $receiver,
com.esotericsoftware.kryo.Kryo kryo)
Can be called on any object to convert it to a byte array (wrapped by
class SerializedBytes ), regardless of whether
the type is marked as serializable or was designed for it (so be careful!). |
static void |
setAttachmentStorage(com.esotericsoftware.kryo.Kryo $receiver,
AttachmentStorage value) |
static <T> T |
useClassLoader(com.esotericsoftware.kryo.Kryo $receiver,
java.lang.ClassLoader cl,
kotlin.jvm.functions.Function0<? extends T> body) |
static void |
writeBytesWithLength(com.esotericsoftware.kryo.io.Output $receiver,
byte[] byteArray) |
public static java.lang.ThreadLocal<com.esotericsoftware.kryo.Kryo> getTHREAD_LOCAL_KRYO()
Serialization utilities, using the Kryo framework with a custom serialiser for immutable data classes and a dead simple, totally non-extensible binary (sub)format.
This is NOT what should be used in any final platform product, rather, the final state should be a precisely specified and standardised binary format with attention paid to anti-malleability, versioning and performance. FIX SBE is a potential candidate: it prioritises performance over convenience and was designed for HFT. Google Protocol Buffers with a minor tightening to make field reordering illegal is another possibility.
FIX SBE: https://real-logic.github.io/simple-binary-encoding/ http://mechanical-sympathy.blogspot.co.at/2014/05/simple-binary-encoding.html Protocol buffers: https://developers.google.com/protocol-buffers/
But for now we use Kryo to maximise prototyping speed.
Note that this code ignores ALL concerns beyond convenience, in particular it ignores:
Performance
Security
This code will happily deserialise literally anything, including malicious streams that would reconstruct classes in invalid states, thus violating system invariants. It isn't designed to handle malicious streams and therefore, isn't usable beyond the prototyping stage. But that's fine: we can revisit serialisation technologies later after a formal evaluation process.
public static <T> T deserialize(byte[] $receiver, com.esotericsoftware.kryo.Kryo kryo)
public static <T> T deserialize(OpaqueBytes $receiver, com.esotericsoftware.kryo.Kryo kryo)
public static WireTransaction SerializedBytesWireTransaction(SerializedBytes<net.corda.core.transactions.WireTransaction> $receiver, com.esotericsoftware.kryo.Kryo kryo)
public static <T> T deserialize(SerializedBytes<T> $receiver, com.esotericsoftware.kryo.Kryo kryo)
public static <T> SerializedBytes<T> serialize(T $receiver, com.esotericsoftware.kryo.Kryo kryo)
Can be called on any object to convert it to a byte array (wrapped by class SerializedBytes
), regardless of whether
the type is marked as serializable or was designed for it (so be careful!).
class SerializedBytes
public static <T> T useClassLoader(com.esotericsoftware.kryo.Kryo $receiver, java.lang.ClassLoader cl, kotlin.jvm.functions.Function0<? extends T> body)
public static void writeBytesWithLength(com.esotericsoftware.kryo.io.Output $receiver, byte[] byteArray)
public static byte[] readBytesWithLength(com.esotericsoftware.kryo.io.Input $receiver)
public static com.esotericsoftware.kryo.Kryo createKryo(com.esotericsoftware.kryo.Kryo k)
public static <T> com.esotericsoftware.kryo.Registration register(com.esotericsoftware.kryo.Kryo $receiver, kotlin.reflect.KClass<T> type, kotlin.jvm.functions.Function2<? super com.esotericsoftware.kryo.Kryo,? super com.esotericsoftware.kryo.io.Input,? extends T> read, kotlin.jvm.functions.Function3<? super com.esotericsoftware.kryo.Kryo,? super com.esotericsoftware.kryo.io.Output,? super T,kotlin.Unit> write)
public static java.lang.String getATTACHMENT_STORAGE()
public static AttachmentStorage getAttachmentStorage(com.esotericsoftware.kryo.Kryo $receiver)
public static void setAttachmentStorage(com.esotericsoftware.kryo.Kryo $receiver, AttachmentStorage value)
public static com.esotericsoftware.kryo.Kryo extendKryoHash(com.esotericsoftware.kryo.Kryo kryo)