@HashCodeAndEqualsPlugin.Enhance public class LambdaFactory extends Object
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 |
---|---|
static Map<ClassFileTransformer,LambdaFactory> |
CLASS_FILE_TRANSFORMERS
A mapping of all registered class file transformers and their lambda factories, linked in their application order.
|
Constructor and Description |
---|
LambdaFactory(Object target,
Method dispatcher)
Creates a new lambda factory.
|
Modifier and Type | Method and Description |
---|---|
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.
|
static boolean |
register(ClassFileTransformer classFileTransformer,
Object classFileFactory)
Registers a class file transformer together with a factory for creating a lambda expression.
|
static boolean |
release(ClassFileTransformer classFileTransformer)
Releases a class file transformer.
|
public static final Map<ClassFileTransformer,LambdaFactory> CLASS_FILE_TRANSFORMERS
public static boolean register(ClassFileTransformer classFileTransformer, Object classFileFactory)
classFileTransformer
- The class file transformer to register.classFileFactory
- The lambda class file factory to use. This factory must define a visible instance method with the signature
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.true
if this is the first registered transformer. This indicates that the LambdaMetafactory
must be instrumented to delegate
to this alternative factory.public static boolean release(ClassFileTransformer classFileTransformer)
classFileTransformer
- The class file transformer to release.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.public static byte[] make(Object caller, String invokedName, Object invokedType, Object samMethodType, Object implMethod, Object instantiatedMethodType, boolean serializable, List<Class<?>> markerInterfaces, List<?> additionalBridges)
caller
- A lookup context representing the creating class of this lambda expression.invokedName
- The name of the lambda expression's represented method.invokedType
- The type of the lambda expression's factory method.samMethodType
- The type of the lambda expression's represented method.implMethod
- A handle representing the target of the lambda expression's method.instantiatedMethodType
- A specialization of the type of the lambda expression's represented method.serializable
- true
if the lambda expression should be serializable.markerInterfaces
- A list of interfaces for the lambda expression to represent.additionalBridges
- A list of additional bridge methods to be implemented by the lambda expression.Copyright © 2014–2019. All rights reserved.