Class RuntimeSerialization
- Since:
- 21.3
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidMakes the provided classes available for serialization at runtime.static voidregisterIncludingAssociatedClasses(Class<?> clazz) Register the specified serialization target class itself and all associated classes.static voidregisterLambdaCapturingClass(Class<?> lambdaCapturingClass) Makes a class available for serialization at runtime that is created for the lambda expressions (a class that has a $deserializeLambda$ method) specified by the lambdaCapturingClass.static voidregisterProxyClass(Class<?>... implementedInterfaces) Makes a dynamic proxy class (class that extendsProxy) available for serialization at runtime that is specified by the given interfaces the proxy class implements.static voidregisterWithTargetConstructorClass(Class<?> clazz, Class<?> customTargetConstructorClazz) Deprecated.
-
Method Details
-
registerIncludingAssociatedClasses
Register the specified serialization target class itself and all associated classes.According to the Java Object Serialization Specification, the associated classes include 1) all the target class' non-static and non-transient fields types and their associated classes; 2) other fields defined in the customised writeObject(ObjectOutputStream) and readObject(ObjectInputStream). This method can automatically explore all possible serialization target classes in the first scenario, but can't figure out the classes in the second scenario.
Another limitation is the specified
clazzmust have no subclasses (effectively final). Otherwise, the actual serialization target class could be any subclass of the specified class at runtime.This API is deprecated; use the
ReflectiveAccessinstead.- Parameters:
clazz- the serialization target class- Since:
- 21.3
-
register
Makes the provided classes available for serialization at runtime.This API is deprecated; use the
ReflectiveAccessinstead.- Since:
- 21.3
-
registerWithTargetConstructorClass
@Deprecated(since="24.2") public static void registerWithTargetConstructorClass(Class<?> clazz, Class<?> customTargetConstructorClazz) Deprecated.Useregister(Class[])instead. All possible custom constructors will be registered automatically.Makes the provided class available for serialization at runtime but uses the provided customTargetConstructorClazz for deserialization.In some cases an application might explicitly make calls to
ReflectionFactory.newConstructorForSerialization(Class<?> cl, Constructor<?> constructorToCall)where the passed `constructorToCall` differs from what would automatically be used if regular deserialization of `cl` would happen. This method exists to also support such usecases.- Since:
- 21.3
-
registerLambdaCapturingClass
Makes a class available for serialization at runtime that is created for the lambda expressions (a class that has a $deserializeLambda$ method) specified by the lambdaCapturingClass.This API is deprecated; use the
ReflectiveAccessinstead.- Since:
- 22.3
-
registerProxyClass
Makes a dynamic proxy class (class that extendsProxy) available for serialization at runtime that is specified by the given interfaces the proxy class implements.This API is deprecated; use the
ReflectiveAccessinstead.- Since:
- 22.3
-
register(Class[])instead.