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

pack-priv final Class InnerClassLambdaMetafactory

extends AbstractValidatingLambdaMetafactory
Class Inheritance
Imports
jdk.internal.constant.ClassOrInterfaceDescImpl, .ConstantUtils, .MethodTypeDescImpl, jdk.internal.misc.CDS, jdk.internal.util.ClassFileDumper, sun.invoke.util.VerifyAccess, .Wrapper, java.io.Serializable, java.lang.classfile.ClassBuilder, .ClassFile, .CodeBuilder, .MethodBuilder, .Opcode, .TypeKind, java.lang.constant.ClassDesc, .MethodTypeDesc, java.lang.reflect.Modifier, java.util.LinkedHashSet, .List, .Set, java.util.function.Consumer, java.lang.classfile.attribute.ExceptionsAttribute, java.lang.classfile.constantpool.ClassEntry, .ConstantPoolBuilder, jdk.internal.vm.annotation.Stable

Lambda metafactory implementation which dynamically creates an inner-class-like class per lambda callsite.
See Also
LambdaMetafactory

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final String[]
private final ClassDesc[]
private final MethodType
private final MethodTypeDesc
private static final boolean
private static final ClassDesc[]
private final ClassDesc
private final MethodTypeDesc
private final String
private static final String
private final ClassEntry
private final String
private static final ClassFileDumper
private final ConstantPoolBuilder
private final boolean
Inherited from java.lang.invoke.AbstractValidatingLambdaMetafactory:
altInterfacesaltMethodscallerdynamicMethodTypefactoryTypeimplClassimplementationimplInfoimplIsInstanceMethodimplKindimplMethodTypeinterfaceClassinterfaceMethodNameinterfaceMethodTypeisSerializabletargetClass

Constructor Summary

AccessConstructor and Description
public
InnerClassLambdaMetafactory(MethodHandles.Lookup
Stacked automatically by VM; represents a lookup context with the accessibility privileges of the caller.
caller
,
MethodType
Stacked automatically by VM; the signature of the invoked method, which includes the expected static type of the returned lambda object, and the static types of the captured arguments for the lambda. In the event that the implementation method is an instance method, the first argument in the invocation signature will correspond to the receiver.
factoryType
,
String
Name of the method in the functional interface to which the lambda or method reference is being converted, represented as a String.
interfaceMethodName
,
MethodType
Type of the method in the functional interface to which the lambda or method reference is being converted, represented as a MethodType.
interfaceMethodType
,
MethodHandle
The implementation method which should be called (with suitable adaptation of argument types, return types, and adjustment for captured arguments) when methods of the resulting functional interface instance are invoked.
implementation
,
MethodType
The signature of the primary functional interface method after type variables are substituted with their instantiation from the capture site
dynamicMethodType
,
boolean
Should the lambda be made serializable? If set, either the target type or one of the additional SAM types must extend Serializable.
isSerializable
,
Class<?>[]
Additional interfaces which the lambda object should implement.
altInterfaces
,
MethodType[]
Method types for additional signatures to be implemented by invoking the implementation method
altMethods
)

General meta-factory constructor, supporting both standard cases and allowing for uncommon options such as serialization or bridging.

Method Summary

Modifier and TypeMethod and Description
private static String
argName(int i)

pack-priv CallSite

Returns:

a CallSite, which, when invoked, will return an instance of the functional interface
buildCallSite
()

Implements abstract java.lang.invoke.AbstractValidatingLambdaMetafactory.buildCallSite.

Build the CallSite.

pack-priv static ClassDesc
classDesc(Class<?> cls)

private void
pack-priv Consumer<CodeBuilder>
forwardingMethod(MethodType methodType)

This method generates a method body which calls the lambda implementation method, converting arguments, as needed.

private void
generateClassInitializer(ClassBuilder clb)

Generate a static field and a static initializer that sets this field to an instance of the lambda

private void
generateConstructor(ClassBuilder clb)

Generate the constructor for the class

private Class<?>

Returns:

a Class which implements the functional interface
generateInnerClass
()

Generate a class file which implements the functional interface, define and return the class.

private void
generateSerializationFriendlyMethods(ClassBuilder clb)

Generate a writeReplace method that supports serialization

private void
generateSerializationHostileMethods(ClassBuilder clb)

Generate a readObject/writeObject method that is hostile to serialization

pack-priv static ClassDesc
private Opcode
private static String
lambdaClassName(Class<?> targetClass)

pack-priv static MethodTypeDesc
private static String
private Class<?>
spinInnerClass()

Spins the lambda proxy class.

Inherited from java.lang.invoke.AbstractValidatingLambdaMetafactory:
validateMetafactoryArgs

Field Detail

ARG_NAME_CACHEback to summary
private static final String[] ARG_NAME_CACHE
Annotations
@Stable
argDescsback to summary
private final ClassDesc[] argDescs
constructorTypeback to summary
private final MethodType constructorType
constructorTypeDescback to summary
private final MethodTypeDesc constructorTypeDesc
disableEagerInitializationback to summary
private static final boolean disableEagerInitialization
EMPTY_CLASSDESC_ARRAYback to summary
private static final ClassDesc[] EMPTY_CLASSDESC_ARRAY
implMethodClassDescback to summary
private final ClassDesc implMethodClassDesc
implMethodDescback to summary
private final MethodTypeDesc implMethodDesc
implMethodNameback to summary
private final String implMethodName
LAMBDA_INSTANCE_FIELDback to summary
private static final String LAMBDA_INSTANCE_FIELD
lambdaClassEntryback to summary
private final ClassEntry lambdaClassEntry
lambdaClassNameback to summary
private final String lambdaClassName
lambdaProxyClassFileDumperback to summary
private static final ClassFileDumper lambdaProxyClassFileDumper
poolback to summary
private final ConstantPoolBuilder pool
useImplMethodHandleback to summary
private final boolean useImplMethodHandle

Constructor Detail

InnerClassLambdaMetafactoryback to summary
public InnerClassLambdaMetafactory(MethodHandles.Lookup caller, MethodType factoryType, String interfaceMethodName, MethodType interfaceMethodType, MethodHandle implementation, MethodType dynamicMethodType, boolean isSerializable, Class<?>[] altInterfaces, MethodType[] altMethods) throws LambdaConversionException

General meta-factory constructor, supporting both standard cases and allowing for uncommon options such as serialization or bridging.

Parameters
caller:MethodHandles.Lookup

Stacked automatically by VM; represents a lookup context with the accessibility privileges of the caller.

factoryType:MethodType

Stacked automatically by VM; the signature of the invoked method, which includes the expected static type of the returned lambda object, and the static types of the captured arguments for the lambda. In the event that the implementation method is an instance method, the first argument in the invocation signature will correspond to the receiver.

interfaceMethodName:String

Name of the method in the functional interface to which the lambda or method reference is being converted, represented as a String.

interfaceMethodType:MethodType

Type of the method in the functional interface to which the lambda or method reference is being converted, represented as a MethodType.

implementation:MethodHandle

The implementation method which should be called (with suitable adaptation of argument types, return types, and adjustment for captured arguments) when methods of the resulting functional interface instance are invoked.

dynamicMethodType:MethodType

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

isSerializable:boolean

Should the lambda be made serializable? If set, either the target type or one of the additional SAM types must extend Serializable.

altInterfaces:Class<?>[]

Additional interfaces which the lambda object should implement.

altMethods:MethodType[]

Method types for additional signatures to be implemented by invoking the implementation method

Exceptions
LambdaConversionException:
If any of the meta-factory protocol invariants are violated

Method Detail

argNameback to summary
private static String argName(int i)
buildCallSiteback to summary
pack-priv CallSite buildCallSite() throws LambdaConversionException

Implements abstract java.lang.invoke.AbstractValidatingLambdaMetafactory.buildCallSite.

Build the CallSite. Generate a class file which implements the functional interface, define the class, if there are no parameters create an instance of the class which the CallSite will return, otherwise, generate handles which will call the class' constructor.

Returns:CallSite

a CallSite, which, when invoked, will return an instance of the functional interface

Annotations
@Override
Exceptions
LambdaConversionException:
If properly formed functional interface is not found
classDescback to summary
pack-priv static ClassDesc classDesc(Class<?> cls)
convertArgumentTypesback to summary
private void convertArgumentTypes(CodeBuilder cob, MethodType samType)
forwardingMethodback to summary
pack-priv Consumer<CodeBuilder> forwardingMethod(MethodType methodType)

This method generates a method body which calls the lambda implementation method, converting arguments, as needed.

generateClassInitializerback to summary
private void generateClassInitializer(ClassBuilder clb)

Generate a static field and a static initializer that sets this field to an instance of the lambda

generateConstructorback to summary
private void generateConstructor(ClassBuilder clb)

Generate the constructor for the class

generateInnerClassback to summary
private Class<?> generateInnerClass() throws LambdaConversionException

Generate a class file which implements the functional interface, define and return the class.

Returns:Class<?>

a Class which implements the functional interface

Exceptions
LambdaConversionException:
If properly formed functional interface is not found
generateSerializationFriendlyMethodsback to summary
private void generateSerializationFriendlyMethods(ClassBuilder clb)

Generate a writeReplace method that supports serialization

generateSerializationHostileMethodsback to summary
private void generateSerializationHostileMethods(ClassBuilder clb)

Generate a readObject/writeObject method that is hostile to serialization

implClassDescback to summary
pack-priv static ClassDesc implClassDesc(Class<?> cls)
invocationOpcodeback to summary
private Opcode invocationOpcode() throws InternalError
lambdaClassNameback to summary
private static String lambdaClassName(Class<?> targetClass)
methodDescback to summary
pack-priv static MethodTypeDesc methodDesc(MethodType mt)
sanitizedTargetClassNameback to summary
private static String sanitizedTargetClassName(Class<?> targetClass)
spinInnerClassback to summary
private Class<?> spinInnerClass() throws LambdaConversionException

Spins the lambda proxy class. This first checks if a lambda proxy class can be loaded from CDS archive. Otherwise, generate the lambda proxy class. If CDS dumping is enabled, it registers the lambda proxy class for including into the CDS archive.

java.lang.invoke back to summary

private Class InnerClassLambdaMetafactory.SerializationSupport

extends Object
Class Inheritance
  • java.lang.Object
  • java.lang.invoke.InnerClassLambdaMetafactory.SerializationSupport

Field Summary

Modifier and TypeField and Description
pack-priv static final ClassDesc
private static final ClassDesc
private static final ClassDesc
private static final ClassDesc
pack-priv static final MethodTypeDesc
pack-priv static final MethodTypeDesc
private static final MethodTypeDesc
private static final MethodTypeDesc
private static final MethodTypeDesc
private static final String
private static final String
private static final String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CD_NotSerializableExceptionback to summary
pack-priv static final ClassDesc CD_NotSerializableException
CD_ObjectInputStreamback to summary
private static final ClassDesc CD_ObjectInputStream
CD_ObjectOutputStreamback to summary
private static final ClassDesc CD_ObjectOutputStream
CD_SerializedLambdaback to summary
private static final ClassDesc CD_SerializedLambda
MTD_CTOR_NOT_SERIALIZABLE_EXCEPTIONback to summary
pack-priv static final MethodTypeDesc MTD_CTOR_NOT_SERIALIZABLE_EXCEPTION
MTD_CTOR_SERIALIZED_LAMBDAback to summary
pack-priv static final MethodTypeDesc MTD_CTOR_SERIALIZED_LAMBDA
MTD_Objectback to summary
private static final MethodTypeDesc MTD_Object
MTD_void_ObjectInputStreamback to summary
private static final MethodTypeDesc MTD_void_ObjectInputStream
MTD_void_ObjectOutputStreamback to summary
private static final MethodTypeDesc MTD_void_ObjectOutputStream
NAME_METHOD_READ_OBJECTback to summary
private static final String NAME_METHOD_READ_OBJECT
NAME_METHOD_WRITE_OBJECTback to summary
private static final String NAME_METHOD_WRITE_OBJECT
NAME_METHOD_WRITE_REPLACEback to summary
private static final String NAME_METHOD_WRITE_REPLACE

Constructor Detail

SerializationSupportback to summary
private SerializationSupport()