< prev index next > src/java.base/share/classes/java/lang/invoke/LambdaMetafactory.java
Print this page
*/
package java.lang.invoke;
import java.io.Serializable;
+ import java.lang.classfile.ClassBuilder;
import java.util.Arrays;
import java.lang.reflect.Array;
import java.util.Objects;
+ import java.util.function.Function;
import jdk.internal.vm.annotation.AOTSafeClassInitializer;
/**
* <p>Methods to facilitate the creation of simple "function objects" that
MethodType factoryType,
MethodType interfaceMethodType,
MethodHandle implementation,
MethodType dynamicMethodType)
throws LambdaConversionException {
- AbstractValidatingLambdaMetafactory mf;
- mf = new InnerClassLambdaMetafactory(Objects.requireNonNull(caller),
- Objects.requireNonNull(factoryType),
- Objects.requireNonNull(interfaceMethodName),
- Objects.requireNonNull(interfaceMethodType),
- Objects.requireNonNull(implementation),
- Objects.requireNonNull(dynamicMethodType),
- false,
- EMPTY_CLASS_ARRAY,
- EMPTY_MT_ARRAY);
+ return metafactoryInternal(caller, interfaceMethodName, factoryType, interfaceMethodType,
+ implementation, dynamicMethodType, null);
+ }
+
+ static CallSite metafactoryInternal(MethodHandles.Lookup caller,
+ String interfaceMethodName,
+ MethodType factoryType,
+ MethodType interfaceMethodType,
+ MethodHandle implementation,
+ MethodType dynamicMethodType,
+ Function<ClassBuilder, Object> finisher)
+ throws LambdaConversionException {
+ AbstractValidatingLambdaMetafactory mf = new InnerClassLambdaMetafactory(
+ Objects.requireNonNull(caller),
+ Objects.requireNonNull(factoryType),
+ Objects.requireNonNull(interfaceMethodName),
+ Objects.requireNonNull(interfaceMethodType),
+ Objects.requireNonNull(implementation),
+ Objects.requireNonNull(dynamicMethodType),
+ false,
+ EMPTY_CLASS_ARRAY,
+ EMPTY_MT_ARRAY,
+ finisher);
mf.validateMetafactoryArgs();
return mf.buildCallSite();
}
/**
public static CallSite altMetafactory(MethodHandles.Lookup caller,
String interfaceMethodName,
MethodType factoryType,
Object... args)
throws LambdaConversionException {
+ return altMetafactoryInternal(caller, interfaceMethodName, factoryType, null, args);
+ }
+
+ static CallSite altMetafactoryInternal(MethodHandles.Lookup caller,
+ String interfaceMethodName,
+ MethodType factoryType,
+ Function<ClassBuilder, Object> finisher,
+ Object... args)
+ throws LambdaConversionException {
Objects.requireNonNull(caller);
Objects.requireNonNull(interfaceMethodName);
Objects.requireNonNull(factoryType);
Objects.requireNonNull(args);
int argIndex = 0;
interfaceMethodType,
implementation,
dynamicMethodType,
isSerializable,
altInterfaces,
- altMethods);
+ altMethods,
+ finisher);
mf.validateMetafactoryArgs();
return mf.buildCallSite();
}
private static <T> T extractArg(Object[] args, int index, Class<T> type) {
< prev index next >