java.lang.invoke.LambdaMetafactory. For this purpose, this class is injected into the class path to serve as a VM-global
singleton and for becoming reachable from the JVM's meta factory. This class keeps a reference to all registered transformers which need
to be explicitly deregistered in order to avoid a memory leak.
| Modifier and Type | Field and Description |
|---|---|
| public static final Map | CLASS_FILE_TRANSFORMERS
A mapping of all registered class file transformers and their lambda factories, linked in their application order. |
| private final Method | dispatcher
The dispatcher method to invoke for creating a new lambda instance. |
| private static final String | FIELD_NAME
The name of the field to access. |
| private final Object | target
The target instance that is a factory for creating lambdas. |
| Access | Constructor and Description |
|---|---|
| public | LambdaFactory(Object
The target instance that is a factory for creating lambdas. target, Method The dispatcher method to invoke for creating a new lambda instance. dispatcher)Creates a new lambda factory. |
| Modifier and Type | Method and Description |
|---|---|
| private byte[] | Returns: A binary representation of the transformed class file.A lookup context representing the creating class of this lambda expression. caller, String The name of the lambda expression's represented method. invokedName, Object The type of the lambda expression's factory method. invokedType, Object The type of the lambda expression's represented method. samMethodType, Object A handle representing the target of the lambda expression's method. implMethod, Object A specialization of the type of the lambda expression's represented method. instantiatedMethodType, boolean true if the lambda expression should be serializable.A list of interfaces for the lambda expression to represent. markerInterfaces, List<?> A list of additional bridge methods to be implemented by the lambda expression. additionalBridges, Collection<ClassFileTransformer> A collection of class file transformers to apply when creating the class. classFileTransformers)Applies this lambda meta factory. |
| public static byte[] | Returns: A binary representation of the transformed class file.A lookup context representing the creating class of this lambda expression. caller, String The name of the lambda expression's represented method. invokedName, Object The type of the lambda expression's factory method. invokedType, Object The type of the lambda expression's represented method. samMethodType, Object A handle representing the target of the lambda expression's method. implMethod, Object A specialization of the type of the lambda expression's represented method. instantiatedMethodType, boolean true if the lambda expression should be serializable.A list of interfaces for the lambda expression to represent. markerInterfaces, List<?> A list of additional bridge methods to be implemented by the lambda expression. additionalBridges)Dispatches the creation of a new class representing a class file. |
| public static boolean | Returns: true if this is the first registered transformer. This indicates that the LambdaMetafactory must be instrumented to delegate
to this alternative factory.The class file transformer to register. classFileTransformer, Object The lambda class file factory to use. This factory must define a visible instance method with the signature
classFileFactory)byte[] make(Object, String, Object, Object, Object, Object, boolean, List, List, Collection. The arguments provided
are the invokedynamic call site's lookup object, the lambda method's name, the factory method's type, the lambda method's
type, the target method's handle, the specialized method type of the lambda expression, a boolean to indicate
serializability, a list of marker interfaces, a list of additional bridges and a collection of class file transformers to
apply.Registers a class file transformer together with a factory for creating a lambda expression. |
| public static boolean | Returns: true if the removed transformer was the last class file transformer registered. This indicates that the LambdaMetafactory must
be instrumented to no longer delegate to this alternative factory.The class file transformer to release. classFileTransformer)Releases a class file transformer. |
| CLASS_FILE_TRANSFORMERS | back to summary |
|---|---|
| public static final Map<ClassFileTransformer, LambdaFactory> CLASS_FILE_TRANSFORMERS A mapping of all registered class file transformers and their lambda factories, linked in their application order. This field must not be accessed directly but only by reading this class from the system class loader.
| |
| dispatcher | back to summary |
|---|---|
| private final Method dispatcher The dispatcher method to invoke for creating a new lambda instance. | |
| FIELD_NAME | back to summary |
|---|---|
| private static final String FIELD_NAME The name of the field to access. | |
| target | back to summary |
|---|---|
| private final Object target The target instance that is a factory for creating lambdas. | |
| LambdaFactory | back to summary |
|---|---|
| public LambdaFactory(Object target, Method dispatcher) Creates a new lambda factory. | |
| invoke | back to summary |
|---|---|
| private byte[] invoke(Object caller, String invokedName, Object invokedType, Object samMethodType, Object implMethod, Object instantiatedMethodType, boolean serializable, List<Class<?>> markerInterfaces, List<?> additionalBridges, Collection<ClassFileTransformer> classFileTransformers) Applies this lambda meta factory.
| |
| make | back to summary |
|---|---|
| public static byte[] make(Object caller, String invokedName, Object invokedType, Object samMethodType, Object implMethod, Object instantiatedMethodType, boolean serializable, List<Class<?>> markerInterfaces, List<?> additionalBridges) Dispatches the creation of a new class representing a class file.
| |
| register | back to summary |
|---|---|
| public static boolean register(ClassFileTransformer classFileTransformer, Object classFileFactory) Registers a class file transformer together with a factory for creating a lambda expression. It is possible to call this method independently of the class loader's context as the supplied injector makes sure that the manipulated collection is the one that is held by the system class loader.
| |
| release | back to summary |
|---|---|
| public static boolean release(ClassFileTransformer classFileTransformer) Releases a class file transformer.
| |