Class MethodHandlesLookupUtils

  • All Implemented Interfaces:
    Utils

    public abstract class MethodHandlesLookupUtils
    extends java.lang.Object
    implements Utils
    The utilities class for MethodHandles.Lookup
    Since:
    1.0.0
    Author:
    Mercy
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.invoke.MethodHandle NOT_FOUND_METHOD_HANDLE
      MethodHandle for Not-Found
      static java.lang.invoke.MethodHandles.Lookup PUBLIC_LOOKUP
      The MethodHandles.Lookup for MethodHandles.publicLookup()
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      protected static java.lang.invoke.MethodHandle find​(java.lang.invoke.MethodHandles.Lookup lookup, java.lang.Class<?> requestedClass, java.lang.String methodName, java.lang.Class[] parameterTypes, ThrowableBiFunction<java.lang.invoke.MethodHandles.Lookup,​java.lang.invoke.MethodType,​java.lang.invoke.MethodHandle> function)  
      protected static java.lang.invoke.MethodHandle find​(java.lang.invoke.MethodHandles.Lookup lookup, java.lang.reflect.Method method, ThrowableBiFunction<java.lang.invoke.MethodHandles.Lookup,​java.lang.invoke.MethodType,​java.lang.invoke.MethodHandle> function)  
      protected static java.lang.invoke.MethodHandle findPublic​(java.lang.Class<?> requestedClass, java.lang.String methodName, java.lang.Class[] parameterTypes, ThrowableBiFunction<java.lang.invoke.MethodHandles.Lookup,​java.lang.invoke.MethodType,​java.lang.invoke.MethodHandle> function)  
      protected static java.lang.invoke.MethodHandle findPublic​(java.lang.reflect.Method method, ThrowableBiFunction<java.lang.invoke.MethodHandles.Lookup,​java.lang.invoke.MethodType,​java.lang.invoke.MethodHandle> function)  
      static java.lang.invoke.MethodHandle findPublicStatic​(java.lang.Class<?> requestedClass, java.lang.String methodName, java.lang.Class... parameterTypes)
      The convenient method to find MethodHandles.Lookup.findStatic(Class, String, MethodType) for public static method
      static java.lang.invoke.MethodHandle findPublicVirtual​(java.lang.Class<?> requestedClass, java.lang.String methodName, java.lang.Class... parameterTypes)
      The convenient method to find MethodHandles.Lookup.findVirtual(Class, String, MethodType) for public method
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • NOT_FOUND_METHOD_HANDLE

        public static final java.lang.invoke.MethodHandle NOT_FOUND_METHOD_HANDLE
        MethodHandle for Not-Found
      • PUBLIC_LOOKUP

        public static final java.lang.invoke.MethodHandles.Lookup PUBLIC_LOOKUP
        The MethodHandles.Lookup for MethodHandles.publicLookup()
    • Method Detail

      • findPublicVirtual

        public static java.lang.invoke.MethodHandle findPublicVirtual​(java.lang.Class<?> requestedClass,
                                                                      java.lang.String methodName,
                                                                      java.lang.Class... parameterTypes)
        The convenient method to find MethodHandles.Lookup.findVirtual(Class, String, MethodType) for public method
        Parameters:
        requestedClass - the class to be looked up
        methodName - the target method name
        parameterTypes - the types of target method parameters
        Returns:
        MethodHandle
      • findPublicStatic

        public static java.lang.invoke.MethodHandle findPublicStatic​(java.lang.Class<?> requestedClass,
                                                                     java.lang.String methodName,
                                                                     java.lang.Class... parameterTypes)
        The convenient method to find MethodHandles.Lookup.findStatic(Class, String, MethodType) for public static method
        Parameters:
        requestedClass - the class to be looked up
        methodName - the target method name
        parameterTypes - the types of target method parameters
        Returns:
        MethodHandle
      • findPublic

        protected static java.lang.invoke.MethodHandle findPublic​(java.lang.Class<?> requestedClass,
                                                                  java.lang.String methodName,
                                                                  java.lang.Class[] parameterTypes,
                                                                  ThrowableBiFunction<java.lang.invoke.MethodHandles.Lookup,​java.lang.invoke.MethodType,​java.lang.invoke.MethodHandle> function)
      • find

        protected static java.lang.invoke.MethodHandle find​(java.lang.invoke.MethodHandles.Lookup lookup,
                                                            java.lang.Class<?> requestedClass,
                                                            java.lang.String methodName,
                                                            java.lang.Class[] parameterTypes,
                                                            ThrowableBiFunction<java.lang.invoke.MethodHandles.Lookup,​java.lang.invoke.MethodType,​java.lang.invoke.MethodHandle> function)
      • findPublic

        protected static java.lang.invoke.MethodHandle findPublic​(java.lang.reflect.Method method,
                                                                  ThrowableBiFunction<java.lang.invoke.MethodHandles.Lookup,​java.lang.invoke.MethodType,​java.lang.invoke.MethodHandle> function)
      • find

        protected static java.lang.invoke.MethodHandle find​(java.lang.invoke.MethodHandles.Lookup lookup,
                                                            java.lang.reflect.Method method,
                                                            ThrowableBiFunction<java.lang.invoke.MethodHandles.Lookup,​java.lang.invoke.MethodType,​java.lang.invoke.MethodHandle> function)