Package sootup.callgraph.invokedynamic
Record Class FunctionalObject
java.lang.Object
java.lang.Record
sootup.callgraph.invokedynamic.FunctionalObject
- Record Components:
site- the invokedynamic statement creating the objectfunctionalInterface- the type of the created objectmarkerInterfaces- additional interfaces (altMetafactoryFLAG_MARKERS)sam- the functional method, plusbridges(FLAG_BRIDGES)implementation- the lambda body / referenced methodcaptureCount- 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 Summary
ConstructorsConstructorDescriptionFunctionalObject(@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 aFunctionalObjectrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleananswers(@NonNull MethodSignature called, @NonNull TypeHierarchy hierarchy) Whether a call ofcalledon this object reachesimplementation(): same functional method (or bridge), declared by the functional interface, a marker, or a supertype.@NonNull Set<MethodSubSignature>bridges()Returns the value of thebridgesrecord component.intReturns the value of thecaptureCountrecord component.@NonNull MethodSignaturedispatchedImplementation(@NonNull View view) The method a call reaches:implementationMethod(), dispatched as declared.final booleanIndicates whether some other object is "equal to" this one.@NonNull ClassTypeReturns the value of thefunctionalInterfacerecord component.final inthashCode()Returns a hash code value for this object.@NonNull DynamicInvokeTargetReturns the value of theimplementationrecord component.@NonNull MethodSignatureThe implementation as concrete method signature (as written in the method handle).booleanWhether a call returns a fresh instance of the implementation's class (Foo::new).Returns the value of themarkerInterfacesrecord component.static @NonNull Optional<FunctionalObject>of(@NonNull Stmt stmt, @NonNull DynamicInvokeResolver resolver, @NonNull View view) The objectstmtcreates, if it assigns aLambdaMetafactoryinvokedynamic whose implementationresolverreports.@NonNull MethodSubSignaturesam()Returns the value of thesamrecord component.intsamArgumentIndex(int j) Where thej-th argument of aansweringcall lands inimplementation():DynamicInvokeTarget.RECEIVER, or a parameter index.@NonNull Stmtsite()Returns the value of thesiterecord component.final StringtoString()Returns a string representation of this record class.
-
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 aFunctionalObjectrecord class.- Parameters:
site- the value for thesiterecord componentfunctionalInterface- the value for thefunctionalInterfacerecord componentmarkerInterfaces- the value for themarkerInterfacesrecord componentsam- the value for thesamrecord componentbridges- the value for thebridgesrecord componentimplementation- the value for theimplementationrecord componentcaptureCount- the value for thecaptureCountrecord component
-
-
Method Details
-
of
public static @NonNull Optional<FunctionalObject> of(@NonNull Stmt stmt, @NonNull DynamicInvokeResolver resolver, @NonNull View view) The objectstmtcreates, if it assigns aLambdaMetafactoryinvokedynamic whose implementationresolverreports. -
answers
Whether a call ofcalledon this object reachesimplementation(): same functional method (or bridge), declared by the functional interface, a marker, or a supertype. -
implementationMethod
The implementation as concrete method signature (as written in the method handle). -
dispatchedImplementation
The method a call reaches:implementationMethod(), dispatched as declared. -
samArgumentIndex
public int samArgumentIndex(int j) Where thej-th argument of aansweringcall lands inimplementation():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
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
site
Returns the value of thesiterecord component.- Returns:
- the value of the
siterecord component
-
functionalInterface
Returns the value of thefunctionalInterfacerecord component.- Returns:
- the value of the
functionalInterfacerecord component
-
markerInterfaces
Returns the value of themarkerInterfacesrecord component.- Returns:
- the value of the
markerInterfacesrecord component
-
sam
Returns the value of thesamrecord component.- Returns:
- the value of the
samrecord component
-
bridges
Returns the value of thebridgesrecord component.- Returns:
- the value of the
bridgesrecord component
-
implementation
Returns the value of theimplementationrecord component.- Returns:
- the value of the
implementationrecord component
-
captureCount
public int captureCount()Returns the value of thecaptureCountrecord component.- Returns:
- the value of the
captureCountrecord component
-