Annotation Interface DefaultMethodHandle


@Documented @Retention(RUNTIME) @Target(PARAMETER) public @interface DefaultMethodHandle
A parameter with this annotation is assigned an instance of java.lang.invoke.MethodHandle which invokes a default method implementation of this method. If such a method is not available, this annotation causes that this delegation target cannot be bound unless nullIfImpossible() is set to true. Note that requesting such a method exposes the default method to reflective access.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    A binder for the DefaultMethodHandle annotation.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Indicates that null should be assigned to this parameter if no default method is invokable.
    Specifies an explicit type that declares the default method to invoke.
  • Element Details

    • targetType

      Class<?> targetType
      Specifies an explicit type that declares the default method to invoke.
      Returns:
      The type declaring the method to invoke or TargetType to indicate that the instrumented method declared the method.
      Default:
      void.class
    • nullIfImpossible

      boolean nullIfImpossible
      Indicates that null should be assigned to this parameter if no default method is invokable.
      Returns:
      true if null should be assigned if no valid method can be assigned.
      Default:
      false