Uses of Class
java.lang.invoke.MethodType
Package
Description
Provides classes that are fundamental to the design of the Java
programming language.
Classes and interfaces to represent nominal descriptors for run-time
entities such as classes or method handles, and classfile entities such as
constant pool entries or
invokedynamic
call sites.Provides low-level access to memory and functions outside the Java runtime.
The
java.lang.invoke
package provides low-level primitives for interacting
with the Java Virtual Machine.The
java.lang.runtime
package provides low-level runtime support
for the Java language.-
Uses of MethodType in java.lang
Modifier and TypeMethodDescriptiondefault MethodType
StackWalker.StackFrame.getMethodType()
Returns theMethodType
representing the parameter types and the return type for the method represented by this stack frame. -
Uses of MethodType in java.lang.constant
Modifier and TypeMethodDescriptionMethodTypeDesc.resolveConstantDesc
(MethodHandles.Lookup lookup) -
Uses of MethodType in java.lang.foreign
Modifier and TypeMethodDescriptionFunctionDescriptor.toMethodType()
Returns the method type consisting of the carrier types of the layouts in this function descriptor. -
Uses of MethodType in java.lang.invoke
Modifier and TypeClassDescriptionfinal class
A method type represents the arguments and return type accepted and returned by a method handle, or the arguments and return type passed and expected by a method handle caller.Modifier and TypeMethodDescriptionfinal MethodType
VarHandle.accessModeType
(VarHandle.AccessMode accessMode) Obtains the access mode type for this VarHandle and a given access mode.MethodType.appendParameterTypes
(Class<?>... ptypesToInsert) Finds or creates a method type with additional parameter types.MethodType.appendParameterTypes
(List<Class<?>> ptypesToInsert) Finds or creates a method type with additional parameter types.MethodType.changeParameterType
(int num, Class<?> nptype) Finds or creates a method type with a single different parameter type.MethodType.changeReturnType
(Class<?> nrtype) Finds or creates a method type with a different return type.MethodType.dropParameterTypes
(int start, int end) Finds or creates a method type with some parameter types omitted.MethodType.erase()
Erases all reference types toObject
.static MethodType
MethodType.fromMethodDescriptorString
(String descriptor, ClassLoader loader) Finds or creates an instance of a method type of the given method descriptor (JVMS 4.3.3).MethodType.generic()
Converts all types, both reference and primitive, toObject
.static MethodType
MethodType.genericMethodType
(int objectArgCount) Finds or creates a method type whose components are allObject
.static MethodType
MethodType.genericMethodType
(int objectArgCount, boolean finalArray) Finds or creates a method type whose components areObject
with an optional trailingObject[]
array.MethodHandleInfo.getMethodType()
Returns the nominal type of the cracked symbolic reference, expressed as a method type.MethodType.insertParameterTypes
(int num, Class<?>... ptypesToInsert) Finds or creates a method type with additional parameter types.MethodType.insertParameterTypes
(int num, List<Class<?>> ptypesToInsert) Finds or creates a method type with additional parameter types.static MethodType
MethodType.methodType
(Class<?> rtype) Finds or creates a method type with the given components.static MethodType
MethodType.methodType
(Class<?> rtype, Class<?> ptype0) Finds or creates a method type with the given components.static MethodType
MethodType.methodType
(Class<?> rtype, Class<?>[] ptypes) Finds or creates an instance of the given method type.static MethodType
MethodType.methodType
(Class<?> rtype, Class<?> ptype0, Class<?>... ptypes) Finds or creates a method type with the given components.static MethodType
MethodType.methodType
(Class<?> rtype, MethodType ptypes) Finds or creates a method type with the given components.static MethodType
MethodType.methodType
(Class<?> rtype, List<Class<?>> ptypes) Finds or creates a method type with the given components.CallSite.type()
Returns the type of this call site's target.MethodHandle.type()
Reports the type of this method handle.MethodType.unwrap()
Converts all wrapper types to their corresponding primitive types.MethodType.wrap()
Converts all primitive types to their corresponding wrapper types.Modifier and TypeMethodDescriptionstatic CallSite
LambdaMetafactory.altMetafactory
(MethodHandles.Lookup caller, String interfaceMethodName, MethodType factoryType, Object... args) Facilitates the creation of simple "function objects" that implement one or more interfaces by delegation to a providedMethodHandle
, after appropriate type adaptation and partial evaluation of arguments.final MethodHandle
MethodHandle.asType
(MethodType newType) Produces an adapter method handle which adapts the type of the current method handle to a new type.MethodHandles.Lookup.bind
(Object receiver, String name, MethodType type) Produces an early-bound method handle for a non-static method.static MethodHandle
MethodHandles.empty
(MethodType type) Produces a method handle of the requested type which ignores any arguments, does nothing, and returns a suitable default depending on the return type.static MethodHandle
MethodHandles.exactInvoker
(MethodType type) Produces a special invoker method handle which can be used to invoke any method handle of the given type, as if byinvokeExact
.static MethodHandle
MethodHandles.explicitCastArguments
(MethodHandle target, MethodType newType) Produces a method handle which adapts the type of the given method handle to a new type by pairwise argument and return type conversion.MethodHandles.Lookup.findConstructor
(Class<?> refc, MethodType type) Produces a method handle which creates an object and initializes it, using the constructor of the specified type.MethodHandles.Lookup.findSpecial
(Class<?> refc, String name, MethodType type, Class<?> specialCaller) Produces an early-bound method handle for a virtual method.MethodHandles.Lookup.findStatic
(Class<?> refc, String name, MethodType type) Produces a method handle for a static method.MethodHandles.Lookup.findVirtual
(Class<?> refc, String name, MethodType type) Produces a method handle for a virtual method.static MethodHandle
MethodHandles.invoker
(MethodType type) Produces a special invoker method handle which can be used to invoke any method handle compatible with the given type, as if byinvoke
.static CallSite
StringConcatFactory.makeConcat
(MethodHandles.Lookup lookup, String name, MethodType concatType) Facilitates the creation of optimized String concatenation methods, that can be used to efficiently concatenate a known number of arguments of known types, possibly after type adaptation and partial evaluation of arguments.static CallSite
StringConcatFactory.makeConcatWithConstants
(MethodHandles.Lookup lookup, String name, MethodType concatType, String recipe, Object... constants) Facilitates the creation of optimized String concatenation methods, that can be used to efficiently concatenate a known number of arguments of known types, possibly after type adaptation and partial evaluation of arguments.static CallSite
LambdaMetafactory.metafactory
(MethodHandles.Lookup caller, String interfaceMethodName, MethodType factoryType, MethodType interfaceMethodType, MethodHandle implementation, MethodType dynamicMethodType) Facilitates the creation of simple "function objects" that implement one or more interfaces by delegation to a providedMethodHandle
, after appropriate type adaptation and partial evaluation of arguments.static MethodType
MethodType.methodType
(Class<?> rtype, MethodType ptypes) Finds or creates a method type with the given components.static MethodHandle
MethodHandles.permuteArguments
(MethodHandle target, MethodType newType, int... reorder) Produces a method handle which adapts the calling sequence of the given method handle to a new type, by reordering the arguments.static MethodHandle
MethodHandles.spreadInvoker
(MethodType type, int leadingArgCount) Produces a method handle which will invoke any method handle of the giventype
, with a given number of trailing arguments replaced by a single trailingObject[]
array.static String
MethodHandleInfo.toString
(int kind, Class<?> defc, String name, MethodType type) Returns a string representation for aMethodHandleInfo
, given the four parts of its symbolic reference.static MethodHandle
MethodHandles.varHandleExactInvoker
(VarHandle.AccessMode accessMode, MethodType type) Produces a special invoker method handle which can be used to invoke a signature-polymorphic access mode method on any VarHandle whose associated access mode type is compatible with the given type.static MethodHandle
MethodHandles.varHandleInvoker
(VarHandle.AccessMode accessMode, MethodType type) Produces a special invoker method handle which can be used to invoke a signature-polymorphic access mode method on any VarHandle whose associated access mode type is compatible with the given type.ModifierConstructorDescriptionprotected
ConstantCallSite
(MethodType targetType, MethodHandle createTargetHook) Creates a call site with a permanent target, possibly bound to the call site itself.MutableCallSite
(MethodType type) Creates a blank call site object with the given method type.VolatileCallSite
(MethodType type) Creates a call site with a volatile binding to its target. -
Uses of MethodType in java.lang.runtime
Modifier and TypeMethodDescriptionstatic CallSite
SwitchBootstraps.enumSwitch
(MethodHandles.Lookup lookup, String invocationName, MethodType invocationType, Object... labels) Bootstrap method for linking aninvokedynamic
call site that implements aswitch
on a target of an enum type.static CallSite
SwitchBootstraps.typeSwitch
(MethodHandles.Lookup lookup, String invocationName, MethodType invocationType, Object... labels) Bootstrap method for linking aninvokedynamic
call site that implements aswitch
on a target of a reference type.