Class DefaultMemberInvoker
java.lang.Object
io.fluxcapacitor.common.reflection.DefaultMemberInvoker
- All Implemented Interfaces:
MemberInvoker
Default implementation of
MemberInvoker
using high-performance method handle-based invocation.
This implementation attempts to convert reflective member access into a compiled lambda expression
via LambdaMetafactory
and MethodHandle
, avoiding the overhead
of standard Java reflection.
Key Features
- Caches compiled lambda invokers for reuse
- Falls back to reflection if lambda creation is not possible
- Supports methods, constructors, and fields (read/write)
- Supports up to 10 parameters per method (beyond which it falls back)
Usage example:
Method m = MyClass.class.getDeclaredMethod("doSomething", String.class);
MemberInvoker invoker = DefaultMemberInvoker.asInvoker(m);
Object result = invoker.invoke(myInstance, "value");
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
static interface
static interface
static interface
static interface
static interface
static interface
static interface
static interface
static interface
static interface
static interface
static interface
static interface
static interface
static interface
static interface
static interface
static interface
static interface
static interface
static interface
-
Method Summary
Modifier and TypeMethodDescriptionstatic MemberInvoker
static MemberInvoker
invoke
(Object target, int parameterCount, IntFunction<?> paramProvider) Invokes the member with the provided number of parameters using a parameter provider.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.fluxcapacitor.common.reflection.MemberInvoker
getMember, invoke, invoke, invoke
-
Method Details
-
asInvoker
-
asInvoker
-
invoke
Description copied from interface:MemberInvoker
Invokes the member with the provided number of parameters using a parameter provider.- Specified by:
invoke
in interfaceMemberInvoker
- Parameters:
target
- the target objectparameterCount
- the number of parameters to useparamProvider
- a function to supply parameters by index- Returns:
- the invocation result
-