Module jdk.dynalink

Class Guards

    • Method Detail

      • isOfClass

        public static MethodHandle isOfClass​(Class<?> clazz,
                                             MethodType type)
        Creates a guard method handle with arguments of a specified type, but with boolean return value. When invoked, it returns true if the first argument is of the specified class (exactly of it, not a subclass). The rest of the arguments will be ignored.
        Parameters:
        clazz - the class of the first argument to test for
        type - the method type
        Returns:
        a method handle testing whether its first argument is of the specified class.
      • isInstance

        public static MethodHandle isInstance​(Class<?> clazz,
                                              MethodType type)
        Creates a method handle with arguments of a specified type, but with boolean return value. When invoked, it returns true if the first argument is instance of the specified class or its subclass). The rest of the arguments will be ignored.
        Parameters:
        clazz - the class of the first argument to test for
        type - the method type
        Returns:
        a method handle testing whether its first argument is of the specified class or subclass.
      • isInstance

        public static MethodHandle isInstance​(Class<?> clazz,
                                              int pos,
                                              MethodType type)
        Creates a method handle with arguments of a specified type, but with boolean return value. When invoked, it returns true if the n'th argument is instance of the specified class or its subclass). The rest of the arguments will be ignored.
        Parameters:
        clazz - the class of the first argument to test for
        pos - the position on the argument list to test
        type - the method type
        Returns:
        a method handle testing whether its first argument is of the specified class or subclass.
      • isArray

        public static MethodHandle isArray​(int pos,
                                           MethodType type)
        Creates a method handle that returns true if the argument in the specified position is a Java array.
        Parameters:
        pos - the position in the argument lit
        type - the method type of the handle
        Returns:
        a method handle that returns true if the argument in the specified position is a Java array; the rest of the arguments are ignored.
      • getClassGuard

        public static MethodHandle getClassGuard​(Class<?> clazz)
        Creates a guard method that tests its only argument for being of an exact particular class.
        Parameters:
        clazz - the class to test for.
        Returns:
        the desired guard method.
      • getInstanceOfGuard

        public static MethodHandle getInstanceOfGuard​(Class<?> clazz)
        Creates a guard method that tests its only argument for being an instance of a particular class.
        Parameters:
        clazz - the class to test for.
        Returns:
        the desired guard method.
      • getIdentityGuard

        public static MethodHandle getIdentityGuard​(Object obj)
        Creates a guard method that tests its only argument for being referentially identical to another object
        Parameters:
        obj - the object used as referential identity test
        Returns:
        the desired guard method.
      • isNull

        public static MethodHandle isNull()
        Returns a guard that tests whether the first argument is null.
        Returns:
        a guard that tests whether the first argument is null.
      • isNotNull

        public static MethodHandle isNotNull()
        Returns a guard that tests whether the first argument is not null.
        Returns:
        a guard that tests whether the first argument is not null.