APIdia Launch Partner
Top Description Fields Constructors Methods
java.lang.invoke

public final Class SerializedLambda

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.io.Serializable, .InvalidObjectException, .ObjectStreamException, java.lang.reflect.Method, java.util.Objects

Serialized form of a lambda expression. The properties of this class represent the information that is present at the lambda factory site, including static metafactory arguments such as the identity of the primary functional interface method and the identity of the implementation method, as well as dynamic metafactory arguments such as values captured from the lexical scope at the time of lambda capture.

Implementors of serializable lambdas, such as compilers or language runtime libraries, are expected to ensure that instances deserialize properly. One means to do so is to ensure that the writeReplace method returns an instance of SerializedLambda, rather than allowing default serialization to proceed.

SerializedLambda has a readResolve method that looks for a (possibly private) static method called $deserializeLambda$(SerializedLambda) in the capturing class, invokes that with itself as the first argument, and returns the result. Lambda classes implementing $deserializeLambda$ are responsible for validating that the properties of the SerializedLambda are consistent with a lambda actually captured by that class.

The identity of a function object produced by deserializing the serialized form is unpredictable, and therefore identity-sensitive operations (such as reference equality, object locking, and System.identityHashCode()) may produce different results in different implementations, or even upon different deserializations in the same implementation.

Since
1.8
See Also
LambdaMetafactory

Field Summary

Modifier and TypeField and Description
private final Object[]
private final Class<?>
private final String
private final String
private final String
private final String
private final int
private final String
private final String
private final String
private static final long

Constructor Summary

AccessConstructor and Description
public
SerializedLambda(Class<?>
The class in which the lambda expression appears
capturingClass
,
String
Name, in slash-delimited form, of static type of the returned lambda object
functionalInterfaceClass
,
String
Name of the functional interface method for the present at the lambda factory site
functionalInterfaceMethodName
,
String
Signature of the functional interface method present at the lambda factory site
functionalInterfaceMethodSignature
,
int
Method handle kind for the implementation method
implMethodKind
,
String
Name, in slash-delimited form, for the class holding the implementation method
implClass
,
String
Name of the implementation method
implMethodName
,
String
Signature of the implementation method
implMethodSignature
,
String
The signature of the primary functional interface method after type variables are substituted with their instantiation from the capture site
instantiatedMethodType
,
Object[]
The dynamic arguments to the lambda factory site, which represent variables captured by the lambda
capturedArgs
)

Create a SerializedLambda from the low-level information present at the lambda factory site.

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

a dynamic argument to the lambda capture site
getCapturedArg
(int
the argument to capture
i
)

Get a dynamic argument to the lambda capture site.

public int

Returns:

the count of dynamic arguments to the lambda capture site
getCapturedArgCount
()

Get the count of dynamic arguments to the lambda capture site.

public String

Returns:

the name of the class that captured this lambda
getCapturingClass
()

Get the name of the class that captured this lambda.

public String

Returns:

the name of the functional interface class to which this lambda has been converted
getFunctionalInterfaceClass
()

Get the name of the invoked type to which this lambda has been converted

public String

Returns:

the name of the primary methods of the functional interface
getFunctionalInterfaceMethodName
()

Get the name of the primary method for the functional interface to which this lambda has been converted.

public String

Returns:

the signature of the primary method of the functional interface
getFunctionalInterfaceMethodSignature
()

Get the signature of the primary method for the functional interface to which this lambda has been converted.

public String

Returns:

the name of the class containing the implementation method
getImplClass
()

Get the name of the class containing the implementation method.

public int

Returns:

the method handle kind of the implementation method
getImplMethodKind
()

Get the method handle kind (see MethodHandleInfo) of the implementation method.

public String

Returns:

the name of the implementation method
getImplMethodName
()

Get the name of the implementation method.

public String

Returns:

the signature of the implementation method
getImplMethodSignature
()

Get the signature of the implementation method.

public final String

Returns:

the signature of the primary functional interface method after type variable processing
getInstantiatedMethodType
()

Get the signature of the primary functional interface method after type variables are substituted with their instantiation from the capture site.

private Object

Returns:

a SerializedLambda
readResolve
()

Resolve a SerializedLambda to an object.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

capturedArgsback to summary
private final Object[] capturedArgs
Annotations
@SuppressWarnings:serial
capturingClassback to summary
private final Class<?> capturingClass
functionalInterfaceClassback to summary
private final String functionalInterfaceClass
functionalInterfaceMethodNameback to summary
private final String functionalInterfaceMethodName
functionalInterfaceMethodSignatureback to summary
private final String functionalInterfaceMethodSignature
implClassback to summary
private final String implClass
implMethodKindback to summary
private final int implMethodKind
implMethodNameback to summary
private final String implMethodName
implMethodSignatureback to summary
private final String implMethodSignature
instantiatedMethodTypeback to summary
private final String instantiatedMethodType
serialVersionUIDback to summary
private static final long serialVersionUID
Annotations
@Serial

Constructor Detail

SerializedLambdaback to summary
public SerializedLambda(Class<?> capturingClass, String functionalInterfaceClass, String functionalInterfaceMethodName, String functionalInterfaceMethodSignature, int implMethodKind, String implClass, String implMethodName, String implMethodSignature, String instantiatedMethodType, Object[] capturedArgs)

Create a SerializedLambda from the low-level information present at the lambda factory site.

Parameters
capturingClass:Class<?>

The class in which the lambda expression appears

functionalInterfaceClass:String

Name, in slash-delimited form, of static type of the returned lambda object

functionalInterfaceMethodName:String

Name of the functional interface method for the present at the lambda factory site

functionalInterfaceMethodSignature:String

Signature of the functional interface method present at the lambda factory site

implMethodKind:int

Method handle kind for the implementation method

implClass:String

Name, in slash-delimited form, for the class holding the implementation method

implMethodName:String

Name of the implementation method

implMethodSignature:String

Signature of the implementation method

instantiatedMethodType:String

The signature of the primary functional interface method after type variables are substituted with their instantiation from the capture site

capturedArgs:Object[]

The dynamic arguments to the lambda factory site, which represent variables captured by the lambda

Method Detail

getCapturedArgback to summary
public Object getCapturedArg(int i)

Get a dynamic argument to the lambda capture site.

Parameters
i:int

the argument to capture

Returns:Object

a dynamic argument to the lambda capture site

getCapturedArgCountback to summary
public int getCapturedArgCount()

Get the count of dynamic arguments to the lambda capture site.

Returns:int

the count of dynamic arguments to the lambda capture site

getCapturingClassback to summary
public String getCapturingClass()

Get the name of the class that captured this lambda.

Returns:String

the name of the class that captured this lambda

getFunctionalInterfaceClassback to summary
public String getFunctionalInterfaceClass()

Get the name of the invoked type to which this lambda has been converted

Returns:String

the name of the functional interface class to which this lambda has been converted

getFunctionalInterfaceMethodNameback to summary
public String getFunctionalInterfaceMethodName()

Get the name of the primary method for the functional interface to which this lambda has been converted.

Returns:String

the name of the primary methods of the functional interface

getFunctionalInterfaceMethodSignatureback to summary
public String getFunctionalInterfaceMethodSignature()

Get the signature of the primary method for the functional interface to which this lambda has been converted.

Returns:String

the signature of the primary method of the functional interface

getImplClassback to summary
public String getImplClass()

Get the name of the class containing the implementation method.

Returns:String

the name of the class containing the implementation method

getImplMethodKindback to summary
public int getImplMethodKind()

Get the method handle kind (see MethodHandleInfo) of the implementation method.

Returns:int

the method handle kind of the implementation method

getImplMethodNameback to summary
public String getImplMethodName()

Get the name of the implementation method.

Returns:String

the name of the implementation method

getImplMethodSignatureback to summary
public String getImplMethodSignature()

Get the signature of the implementation method.

Returns:String

the signature of the implementation method

getInstantiatedMethodTypeback to summary
public final String getInstantiatedMethodType()

Get the signature of the primary functional interface method after type variables are substituted with their instantiation from the capture site.

Returns:String

the signature of the primary functional interface method after type variable processing

readResolveback to summary
private Object readResolve() throws ObjectStreamException

Resolve a SerializedLambda to an object.

Returns:Object

a SerializedLambda

Annotations
@Serial
Exceptions
ObjectStreamException:
if the object is not valid
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override