Class SerializedLambda
- All Implemented Interfaces:
Serializable
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.
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:
Constructor Summary
Constructor | Description |
---|---|
SerializedLambda |
Create a SerializedLambda from the low-level information present at the lambda factory site. |
Method Summary
Modifier and Type | Method | Description |
---|---|---|
Object |
getCapturedArg |
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. |
final String |
getInstantiatedMethodType() |
Get the signature of the primary functional interface method after type variables are substituted with their instantiation from the capture site. |
Constructor Details
SerializedLambda
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.- Parameters:
-
capturingClass
- The class in which the lambda expression appears -
functionalInterfaceClass
- Name, in slash-delimited form, of static type of the returned lambda object -
functionalInterfaceMethodName
- Name of the functional interface method for the present at the lambda factory site -
functionalInterfaceMethodSignature
- Signature of the functional interface method present at the lambda factory site -
implMethodKind
- Method handle kind for the implementation method -
implClass
- Name, in slash-delimited form, for the class holding the implementation method -
implMethodName
- Name of the implementation method -
implMethodSignature
- Signature of the implementation method -
instantiatedMethodType
- The signature of the primary functional interface method after type variables are substituted with their instantiation from the capture site -
capturedArgs
- The dynamic arguments to the lambda factory site, which represent variables captured by the lambda
Method Details
getCapturingClass
public String getCapturingClass()
- Returns:
- the name of the class that captured this lambda
getFunctionalInterfaceClass
public String getFunctionalInterfaceClass()
- Returns:
- the name of the functional interface class to which this lambda has been converted
getFunctionalInterfaceMethodName
public String getFunctionalInterfaceMethodName()
- Returns:
- the name of the primary methods of the functional interface
getFunctionalInterfaceMethodSignature
public String getFunctionalInterfaceMethodSignature()
- Returns:
- the signature of the primary method of the functional interface
getImplClass
public String getImplClass()
- Returns:
- the name of the class containing the implementation method
getImplMethodName
public String getImplMethodName()
- Returns:
- the name of the implementation method
getImplMethodSignature
public String getImplMethodSignature()
- Returns:
- the signature of the implementation method
getImplMethodKind
public int getImplMethodKind()
MethodHandleInfo
) of the implementation method.- Returns:
- the method handle kind of the implementation method
getInstantiatedMethodType
public final String getInstantiatedMethodType()
- Returns:
- the signature of the primary functional interface method after type variable processing
getCapturedArgCount
public int getCapturedArgCount()
- Returns:
- the count of dynamic arguments to the lambda capture site
getCapturedArg
public Object getCapturedArg(int i)
- Parameters:
-
i
- the argument to capture - Returns:
- a dynamic argument to the lambda capture site
© 1993, 2021, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/invoke/SerializedLambda.html