corda / net.corda.core.serialization

Package net.corda.core.serialization

Types

CheckpointCustomSerializer

Allows CorDapps to provide custom serializers for classes that do not serialize successfully during a checkpoint. In this case, a proxy serializer can be written that implements this interface whose purpose is to move between unserializable types and an intermediate representation.

interface CheckpointCustomSerializer<OBJ, PROXY>

ClassWhitelist

interface ClassWhitelist

ContextPropertyKeys

Set of well known properties that may be set on a serialization context. This doesn't preclude others being set that aren't keyed on this enumeration, but for general use properties adding a well known key here is preferred.

enum class ContextPropertyKeys

CustomSerializationScheme

interface CustomSerializationScheme

EncodingWhitelist

interface EncodingWhitelist

ObjectWithCompatibleContext

data class ObjectWithCompatibleContext<out T : Any>

SerializationContext

Parameters to serialization and deserialization.

interface SerializationContext

SerializationCustomSerializer

Allows CorDapps to provide custom serializers for third party libraries where those libraries cannot be recompiled with the -parameters flag rendering their classes natively serializable by Corda. In this case a proxy serializer can be written that extends this type whose purpose is to move between those an unserializable types and an intermediate representation.

interface SerializationCustomSerializer<OBJ, PROXY>

SerializationDefaults

Global singletons to be used as defaults that are injected elsewhere (generally, in the node or in RPC client).

object SerializationDefaults

SerializationEncoding

interface SerializationEncoding

SerializationFactory

An abstraction for serializing and deserializing objects, with support for versioning of the wire format via a header / prefix in the bytes.

abstract class SerializationFactory

SerializationMagic

typealias SerializationMagic = ByteSequence

SerializationSchemeContext

This is used to pass information into CustomSerializationScheme about how the object should be (de)serialized. This context can change depending on the specific circumstances in the node when (de)serialization occurs.

interface SerializationSchemeContext

SerializationToken

This represents a token in the serialized stream for an instance of a type that implements SerializeAsToken.

interface SerializationToken

SerializationWhitelist

Provide a subclass of this via the java.util.ServiceLoader mechanism to be able to whitelist types for serialisation that you cannot otherwise annotate. The name of the class must appear in a text file on the classpath under the path META-INF/services/net.corda.core.serialization.SerializationWhitelist

interface SerializationWhitelist

SerializeAsToken

This interface should be implemented by classes that want to substitute a token representation of themselves if they are serialized because they have a lot of internal state that does not serialize (well).

interface SerializeAsToken

SerializeAsTokenContext

A context for mapping SerializationTokens to/from SerializeAsTokens.

interface SerializeAsTokenContext

SerializedBytes

A type safe wrapper around a byte array that contains a serialised object. You can call SerializedBytes.deserialize to get the original object back.

class SerializedBytes<T : Any> : OpaqueBytes

SingletonSerializationToken

A class representing a SerializationToken for some object that is not serializable but can be looked up (when deserialized) via just the class name.

class SingletonSerializationToken : SerializationToken

SingletonSerializeAsToken

A base class for implementing large objects / components / services that need to serialize themselves to a string token to indicate which instance the token is a serialized form of.

abstract class SingletonSerializeAsToken : SerializeAsToken

Annotations

ConstructorForDeserialization

Annotation indicating a constructor to be used to reconstruct instances of a class during deserialization.

annotation class ConstructorForDeserialization

CordaSerializable

This annotation is a marker to indicate that a class is permitted and intended to be serialized as part of Node messaging.

annotation class CordaSerializable

CordaSerializationTransformEnumDefault

This annotation is used to mark an enumerated type as having had a new constant appended to it. For each additional constant added a new annotation should be appended to the class. If more than one is required the wrapper annotation CordaSerializationTransformEnumDefaults should be used to encapsulate them

annotation class CordaSerializationTransformEnumDefault

CordaSerializationTransformEnumDefaults

This annotation is used to mark an enumerated type as having had multiple members added, It acts as a container annotation for instances of CordaSerializationTransformEnumDefault, each of which details individual additions.

annotation class CordaSerializationTransformEnumDefaults

CordaSerializationTransformRename

This annotation is used to mark a class has having had a property element. It is used by the AMQP deserializer to allow instances with different versions of the class on their Class Path to successfully deserialize the object.

annotation class CordaSerializationTransformRename

CordaSerializationTransformRenames

This annotation is used to mark a class as having had multiple elements renamed as a container annotation for instances of CordaSerializationTransformRename, each of which details an individual rename.

annotation class CordaSerializationTransformRenames

DeprecatedConstructorForDeserialization

This annotation is a marker to indicate which secondary constructors should be considered, and in which order, for evolving objects during their deserialization.

annotation class DeprecatedConstructorForDeserialization

SerializableCalculatedProperty

Used to annotate methods which expose calculated values that we want to be serialized for use by the class carpenter.

annotation class SerializableCalculatedProperty

Exceptions

MissingAttachmentsException

Thrown during deserialization to indicate that an attachment needed to construct the WireTransaction is not found.

class MissingAttachmentsException : CordaException

MissingAttachmentsRuntimeException

class MissingAttachmentsRuntimeException : CordaRuntimeException

Extensions for External Classes

java.sql.Blob

kotlin.ByteArray

Properties

AMQP_ENVELOPE_CACHE_INITIAL_CAPACITY

const val AMQP_ENVELOPE_CACHE_INITIAL_CAPACITY: Int

AMQP_ENVELOPE_CACHE_PROPERTY

const val AMQP_ENVELOPE_CACHE_PROPERTY: String

DESERIALIZATION_CACHE_PROPERTY

const val DESERIALIZATION_CACHE_PROPERTY: String

Functions

deserialize

Convenience extension method for deserializing a ByteSequence, utilising the defaults.

fun <T : Any> ByteSequence.deserialize(serializationFactory: SerializationFactory = SerializationFactory.defaultFactory, context: SerializationContext = serializationFactory.defaultContext): T

Convenience extension method for deserializing SerializedBytes with type matching, utilising the defaults.

fun <T : Any> SerializedBytes<T>.deserialize(serializationFactory: SerializationFactory = SerializationFactory.defaultFactory, context: SerializationContext = serializationFactory.defaultContext): T

deserializeWithCompatibleContext

Additionally returns SerializationContext which was used for encoding. It might be helpful to know SerializationContext to use the same encoding in the reply.

fun <T : Any> ByteSequence.deserializeWithCompatibleContext(serializationFactory: SerializationFactory = SerializationFactory.defaultFactory, context: SerializationContext = serializationFactory.defaultContext): ObjectWithCompatibleContext<T>

serialize

Convenience extension method for serializing an object of type T, utilising the defaults.

fun <T : Any> T.serialize(serializationFactory: SerializationFactory = SerializationFactory.defaultFactory, context: SerializationContext = serializationFactory.defaultContext): SerializedBytes<T>

withWhitelist

Helper method to return a new context based on this context with the given list of classes specifically whitelisted.

fun SerializationContext.withWhitelist(classes: List<Class<*>>): SerializationContext