Package com.sun.jna.internal
Klasse ReflectionUtils
java.lang.Object
com.sun.jna.internal.ReflectionUtils
Helper class to invoke default method reflectively.
This class is intented to be used only be JNA itself.
This implementation is inspired by: Correct Reflective Access to Interface Default Methods in Java 8, 9, 10
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic Object
getMethodHandle
(Method method) Retrieve the method handle, that can be used to invoke the provided method.static Object
invokeDefaultMethod
(Object target, Object methodHandle, Object... args) Invokes a default method reflectively.static boolean
Check if the supplied method object represents a default method.
-
Konstruktordetails
-
ReflectionUtils
public ReflectionUtils()
-
-
Methodendetails
-
isDefault
Check if the supplied method object represents a default method.This is the reflective equivalent of
method.isDefault()
.- Parameter:
method
-- Gibt zurück:
- true if JVM supports default methods and
method
is a default method
-
getMethodHandle
Retrieve the method handle, that can be used to invoke the provided method. It is only intended to be used to call default methods on interfaces.- Parameter:
method
-- Gibt zurück:
- method handle that can be used to invoke the supplied method
- Löst aus:
Exception
-
invokeDefaultMethod
public static Object invokeDefaultMethod(Object target, Object methodHandle, Object... args) throws Throwable Invokes a default method reflectively. The method must be called with the method handle for a default method on an interfaces.- Parameter:
target
- object to invoke the supplied method handle onmethodHandle
- retrieved viagetMethodHandle(java.lang.reflect.Method)
args
-- Gibt zurück:
- result of the invokation
- Löst aus:
Throwable
-