Class SerializedLambda
- All Implemented Interfaces:
Serializable
Implementors of serializable lambdas, such as compilers or languageruntime libraries, are expected to ensure that instances deserialize properly.One means to do so is to ensure that thewriteReplace method returnsan instance ofSerializedLambda, rather than allowing defaultserialization to proceed.
SerializedLambda has areadResolve method that looks fora (possibly private) static method called$deserializeLambda$(SerializedLambda) in the capturing class, invokesthat with itself as the first argument, and returns the result. Lambda classesimplementing$deserializeLambda$ are responsible for validatingthat the properties of theSerializedLambda are consistent with alambda actually captured by that class.
The identity of a function object produced by deserializing the serializedform is unpredictable, and therefore identity-sensitive operations (such asreference equality, object locking, andSystem.identityHashCode()) mayproduce different results in different implementations, or even upondifferent deserializations in the same implementation.
- Since:
- 1.8
- See Also:
Constructor Summary
ConstructorsConstructorDescriptionSerializedLambda(Class<?> capturingClass,String functionalInterfaceClass,String functionalInterfaceMethodName,String functionalInterfaceMethodSignature, int implMethodKind,String implClass,String implMethodName,String implMethodSignature,String instantiatedMethodType,Object[] capturedArgs) Create aSerializedLambdafrom the low-level information presentat the lambda factory site.Method Summary
Modifier and TypeMethodDescriptiongetCapturedArg(int i) Get a dynamic argument to the lambda capture site.intGet the count of dynamic arguments to the lambda capture site.Get the name of the class that captured this lambda.Get the name of the invoked type to which thislambda has been convertedGet the name of the primary method for the functional interfaceto which this lambda has been converted.Get the signature of the primary method for the functionalinterface to which this lambda has been converted.Get the name of the class containing the implementationmethod.intGet the method handle kind (seeMethodHandleInfo) ofthe implementation method.Get the name of the implementation method.Get the signature of the implementation method.finalStringGet the signature of the primary functional interface methodafter type variables are substituted with their instantiationfrom 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) Create aSerializedLambdafrom the low-level information presentat the lambda factory site.- Parameters:
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 lambda
Method Details
getCapturingClass
Get the name of the class that captured this lambda.- Returns:
- the name of the class that captured this lambda
getFunctionalInterfaceClass
Get the name of the invoked type to which thislambda has been converted- Returns:
- the name of the functional interface class to whichthis lambda has been converted
getFunctionalInterfaceMethodName
Get the name of the primary method for the functional interfaceto which this lambda has been converted.- Returns:
- the name of the primary methods of the functional interface
getFunctionalInterfaceMethodSignature
Get the signature of the primary method for the functionalinterface to which this lambda has been converted.- Returns:
- the signature of the primary method of the functionalinterface
getImplClass
Get the name of the class containing the implementationmethod.- Returns:
- the name of the class containing the implementationmethod
getImplMethodName
Get the name of the implementation method.- Returns:
- the name of the implementation method
getImplMethodSignature
Get the signature of the implementation method.- Returns:
- the signature of the implementation method
getImplMethodKind
public int getImplMethodKind()Get the method handle kind (seeMethodHandleInfo) ofthe implementation method.- Returns:
- the method handle kind of the implementation method
getInstantiatedMethodType
Get the signature of the primary functional interface methodafter type variables are substituted with their instantiationfrom the capture site.- Returns:
- the signature of the primary functional interface methodafter type variable processing
getCapturedArgCount
public int getCapturedArgCount()Get the count of dynamic arguments to the lambda capture site.- Returns:
- the count of dynamic arguments to the lambda capture site
getCapturedArg
Get a dynamic argument to the lambda capture site.- Parameters:
i- the argument to capture- Returns:
- a dynamic argument to the lambda capture site