Class BootstrapMethodHandleResolver

java.lang.Object
sootup.callgraph.invokedynamic.BootstrapMethodHandleResolver
All Implemented Interfaces:
DynamicInvokeResolver

public final class BootstrapMethodHandleResolver extends Object implements DynamicInvokeResolver
Resolves an invokedynamic call site to every method referenced by a MethodHandle among its bootstrap arguments. For LambdaMetafactory call sites that is the lambda body or method reference, marked as DynamicInvokeTarget.lambdaImplementation() so pointer analyses can bind captured values. Other bootstraps (e.g. ObjectMethods for records) contribute their method handles as plain targets.
  • Method Details

    • desugar

      public @NonNull Body desugar(@NonNull SootMethod method, @NonNull Body body, @NonNull View view)
      Applies InvokeDynamicDesugarer (string concatenation, record methods) unless the view's frontend already did.
      Specified by:
      desugar in interface DynamicInvokeResolver
      Returns:
      body itself if nothing changed, else a rewritten copy - the same one on each call, so statements of call graph edges and of later passes over the body match
    • resolve

      public @NonNull List<DynamicInvokeTarget> resolve(@NonNull JDynamicInvokeExpr expr)
      Specified by:
      resolve in interface DynamicInvokeResolver
      Parameters:
      expr - the invokedynamic expression
      Returns:
      the methods expr may transfer control to; empty if unresolved
    • isLambdaMetafactory

      public static boolean isLambdaMetafactory(@NonNull JDynamicInvokeExpr expr)
      Whether expr is bootstrapped by LambdaMetafactory.(alt)metafactory.
    • lambdaImplementationHandle

      public static @Nullable MethodHandle lambdaImplementationHandle(@NonNull JDynamicInvokeExpr expr)
      The implementation method handle of a LambdaMetafactory call site - its first MethodHandle bootstrap argument - or null if expr is not one.