public final class SerializedLambda extends Object implements Serializable
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.
LambdaMetafactory
,
Serialized FormConstructor and Description |
---|
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. |
Modifier and Type | Method and Description |
---|---|
Object |
getCapturedArg(int i)
Get a dynamic argument to the lambda capture site.
|
int |
getCapturedArgCount()
Get the count of dynamic arguments to the lambda capture site.
|
String |
getCapturingClass()
Get the name of the class that captured this lambda.
|
String |
getFunctionalInterfaceClass()
Get the name of the invoked type to which this
lambda has been converted
|
String |
getFunctionalInterfaceMethodName()
Get the name of the primary method for the functional interface
to which this lambda has been converted.
|
String |
getFunctionalInterfaceMethodSignature()
Get the signature of the primary method for the functional
interface to which this lambda has been converted.
|
String |
getImplClass()
Get the name of the class containing the implementation
method.
|
int |
getImplMethodKind()
Get the method handle kind (see
MethodHandleInfo ) of
the implementation method. |
String |
getImplMethodName()
Get the name of the implementation method.
|
String |
getImplMethodSignature()
Get the signature of the implementation method.
|
String |
getInstantiatedMethodType()
Get the signature of the primary functional interface method
after type variables are substituted with their instantiation
from the capture site.
|
String |
toString()
Answers a string containing a concise, human-readable
description of the receiver.
|
public SerializedLambda(Class<?> capturingClass, String functionalInterfaceClass, String functionalInterfaceMethodName, String functionalInterfaceMethodSignature, int implMethodKind, String implClass, String implMethodName, String implMethodSignature, String instantiatedMethodType, Object[] capturedArgs)
SerializedLambda
from the low-level information present
at the lambda factory site.capturingClass
- The class in which the lambda expression appearsfunctionalInterfaceClass
- Name, in slash-delimited form, of static
type of the returned lambda objectfunctionalInterfaceMethodName
- Name of the functional interface
method for the present at the
lambda factory sitefunctionalInterfaceMethodSignature
- Signature of the functional
interface method present at
the lambda factory siteimplMethodKind
- Method handle kind for the implementation methodimplClass
- Name, in slash-delimited form, for the class holding
the implementation methodimplMethodName
- Name of the implementation methodimplMethodSignature
- Signature of the implementation methodinstantiatedMethodType
- The signature of the primary functional
interface method after type variables
are substituted with their instantiation
from the capture sitecapturedArgs
- The dynamic arguments to the lambda factory site,
which represent variables captured by
the lambdapublic String getCapturingClass()
public String getFunctionalInterfaceClass()
public String getFunctionalInterfaceMethodName()
public String getFunctionalInterfaceMethodSignature()
public String getImplClass()
public String getImplMethodName()
public String getImplMethodSignature()
public int getImplMethodKind()
MethodHandleInfo
) of
the implementation method.public final String getInstantiatedMethodType()
public int getCapturedArgCount()
public Object getCapturedArg(int i)
i
- the argument to capture Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.