Record Class FunctionalObject

java.lang.Object
java.lang.Record
sootup.callgraph.invokedynamic.FunctionalObject
Record Components:
site - the invokedynamic statement creating the object
functionalInterface - the type of the created object
markerInterfaces - additional interfaces (altMetafactory FLAG_MARKERS)
sam - the functional method, plus bridges (FLAG_BRIDGES)
implementation - the lambda body / referenced method
captureCount - number of values the call site captures (its argument count)

public record FunctionalObject(@NonNull Stmt site, @NonNull ClassType functionalInterface, @NonNull Set<ClassType> markerInterfaces, @NonNull MethodSubSignature sam, @NonNull Set<MethodSubSignature> bridges, @NonNull DynamicInvokeTarget implementation, int captureCount) extends Record
The object a LambdaMetafactory call site creates (lambda / method reference): an anonymous implementation of functionalInterface() whose single abstract method sam() forwards to implementation(). Algorithms dispatch calls on it like on any object: a call that answers(sootup.core.signatures.MethodSignature, sootup.core.typehierarchy.TypeHierarchy) it reaches the implementation, with arguments placed by samArgumentIndex(int).
  • Constructor Details

    • FunctionalObject

      public FunctionalObject(@NonNull Stmt site, @NonNull ClassType functionalInterface, @NonNull Set<ClassType> markerInterfaces, @NonNull MethodSubSignature sam, @NonNull Set<MethodSubSignature> bridges, @NonNull DynamicInvokeTarget implementation, int captureCount)
      Creates an instance of a FunctionalObject record class.
      Parameters:
      site - the value for the site record component
      functionalInterface - the value for the functionalInterface record component
      markerInterfaces - the value for the markerInterfaces record component
      sam - the value for the sam record component
      bridges - the value for the bridges record component
      implementation - the value for the implementation record component
      captureCount - the value for the captureCount record component
  • Method Details

    • of

      public static @NonNull Optional<FunctionalObject> of(@NonNull Stmt stmt, @NonNull DynamicInvokeResolver resolver, @NonNull View view)
      The object stmt creates, if it assigns a LambdaMetafactory invokedynamic whose implementation resolver reports.
    • answers

      public boolean answers(@NonNull MethodSignature called, @NonNull TypeHierarchy hierarchy)
      Whether a call of called on this object reaches implementation(): same functional method (or bridge), declared by the functional interface, a marker, or a supertype.
    • implementationMethod

      public @NonNull MethodSignature implementationMethod()
      The implementation as concrete method signature (as written in the method handle).
    • dispatchedImplementation

      public @NonNull MethodSignature dispatchedImplementation(@NonNull View view)
      The method a call reaches: implementationMethod(), dispatched as declared.
    • samArgumentIndex

      public int samArgumentIndex(int j)
      Where the j-th argument of a answering call lands in implementation(): DynamicInvokeTarget.RECEIVER, or a parameter index. Captured values come first (DynamicInvokeTarget.captureParameterIndex(int)); an unbound receiver reference (String::length) takes its receiver from the first argument.
    • isConstructorReference

      public boolean isConstructorReference()
      Whether a call returns a fresh instance of the implementation's class (Foo::new).
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • site

      public @NonNull Stmt site()
      Returns the value of the site record component.
      Returns:
      the value of the site record component
    • functionalInterface

      public @NonNull ClassType functionalInterface()
      Returns the value of the functionalInterface record component.
      Returns:
      the value of the functionalInterface record component
    • markerInterfaces

      public @NonNull Set<ClassType> markerInterfaces()
      Returns the value of the markerInterfaces record component.
      Returns:
      the value of the markerInterfaces record component
    • sam

      public @NonNull MethodSubSignature sam()
      Returns the value of the sam record component.
      Returns:
      the value of the sam record component
    • bridges

      public @NonNull Set<MethodSubSignature> bridges()
      Returns the value of the bridges record component.
      Returns:
      the value of the bridges record component
    • implementation

      public @NonNull DynamicInvokeTarget implementation()
      Returns the value of the implementation record component.
      Returns:
      the value of the implementation record component
    • captureCount

      public int captureCount()
      Returns the value of the captureCount record component.
      Returns:
      the value of the captureCount record component