findStableLambdaName
public static String findStableLambdaName(ClassInitializationPlugin cip,
Providers providers,
ResolvedJavaType lambdaType,
OptionValues options,
DebugContext debug,
Object ctx)
throws RuntimeException
Creates a stable name for a lambda by hashing all the invokes in the lambda. Lambda class
names are typically created based on an increasing atomic counter (e.g.
Test$$Lambda$23). A stable name is created by replacing the substring after
"$$Lambda$" with a hash of the method descriptor for each method invoked by the
lambda.
Starting from JDK17, the lambda classes can have additional interfaces that lambda should
implement. This further means that lambda can have more than one public method (public and
not bridge).
The scala lambda classes have by default one additional interface with one method. This
method has the same signature as the original one but with generalized parameters (all
parameters are Object types) and serves as a wrapper that casts parameters to specialized
types and calls an original method.
- Parameters:
cip - plugin to
load new types
providers - providers to use when processing the lambda code
lambdaType - the lambda type to analyze
options - options to use when analyzing the lamda code
debug - debug context to nest the analysis into
ctx - context to use for the
DebugContext.scope(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object)
- Returns:
- stable name for the lambda class
- Throws:
RuntimeException