Class ReferenceAdapters

java.lang.Object
io.micronaut.sourcegen.bytecode.core.ReferenceAdapters

@Internal public final class ReferenceAdapters extends Object
The method references a metafactory cannot link to their method directly, which are written as a lambda calling it.
Since:
2.3
  • Method Details

    • varargsAdapter

      public static @Nullable ExpressionDef.Lambda varargsAdapter(MethodReferenceExpression reference)
      A reference to a method of variable arity that the functional method passes the values of the array to - a Function<String, String> of a <T> String component(T...) - as the lambda javac writes for it, packing them into an array of the type they are passed with.
      Parameters:
      reference - The reference
      Returns:
      The lambda, or null where the method takes the arguments as they are passed
    • capturesReceiverValue

      public static boolean capturesReceiverValue(MethodReferenceExpression reference)
      Whether the receiver of a reference is read where the adapter is invoked unless the writer reads it first: a field, which a bound reference reads once, where it is created. The writer reads it, checks it is not null, holds it in a local and passes the local to varargsAdapter(MethodReferenceExpression, ExpressionDef).
      Parameters:
      reference - The reference
      Returns:
      Whether the receiver is read into a local before the adapter is written
    • varargsAdapter

      public static @Nullable ExpressionDef.Lambda varargsAdapter(MethodReferenceExpression reference, @Nullable ExpressionDef instance)
      The adapter of varargsAdapter(MethodReferenceExpression), invoking the method on the receiver given: the local a writer holds the value of a field receiver in.
      Parameters:
      reference - The reference
      instance - The receiver, or null for a static method
      Returns:
      The lambda, or null where the method takes the arguments as they are passed