Class DefaultMemberInvoker
java.lang.Object
io.fluxzero.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 interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interface -
Method Summary
Modifier and TypeMethodDescriptionstatic MemberInvokerstatic MemberInvokerinvoke(Object target, int parameterCount, IntFunction<?> paramProvider) Invokes the member with the provided number of parameters using a parameter provider.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface MemberInvoker
getMember, invoke, invoke, invoke
-
Method Details
-
asInvoker
-
asInvoker
-
invoke
Description copied from interface:MemberInvokerInvokes the member with the provided number of parameters using a parameter provider.- Specified by:
invokein interfaceMemberInvoker- Parameters:
target- the target objectparameterCount- the number of parameters to useparamProvider- a function to supply parameters by index- Returns:
- the invocation result
-