< prev index next > src/java.base/share/classes/java/lang/invoke/LambdaMetafactory.java
Print this page
import java.io.Serializable;
import java.util.Arrays;
import java.lang.reflect.Array;
import java.util.Objects;
+ import jdk.internal.access.JavaLangInvokeAccess.ReflectableLambdaInfo;
import jdk.internal.vm.annotation.AOTSafeClassInitializer;
/**
* <p>Methods to facilitate the creation of simple "function objects" that
* implement one or more interfaces by delegation to a provided {@link MethodHandle},
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,
+ ReflectableLambdaInfo reflectableLambdaInfo)
+ 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,
+ reflectableLambdaInfo);
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,
+ ReflectableLambdaInfo reflectableLambdaInfo,
+ Object... args)
+ throws LambdaConversionException {
Objects.requireNonNull(caller);
Objects.requireNonNull(interfaceMethodName);
Objects.requireNonNull(factoryType);
Objects.requireNonNull(args);
int argIndex = 0;
if (altInterfaceCount > 0) {
altInterfaces = extractArgs(args, argIndex, Class.class, altInterfaceCount);
argIndex += altInterfaceCount;
}
}
+
if ((flags & FLAG_BRIDGES) != 0) {
int altMethodCount = extractArg(args, argIndex++, Integer.class);
if (altMethodCount < 0) {
throw new IllegalArgumentException("negative argument count");
}
}
}
AbstractValidatingLambdaMetafactory mf
= new InnerClassLambdaMetafactory(caller,
- factoryType,
- interfaceMethodName,
- interfaceMethodType,
- implementation,
- dynamicMethodType,
- isSerializable,
- altInterfaces,
- altMethods);
+ factoryType,
+ interfaceMethodName,
+ interfaceMethodType,
+ implementation,
+ dynamicMethodType,
+ isSerializable,
+ altInterfaces,
+ altMethods,
+ reflectableLambdaInfo);
mf.validateMetafactoryArgs();
return mf.buildCallSite();
}
private static <T> T extractArg(Object[] args, int index, Class<T> type) {
< prev index next >