Skip to content

Commit 2881b09

Browse files
committed
Add a comment describing SootClass name for lambdas
1 parent 05030ec commit 2881b09

File tree

1 file changed

+8
-1
lines changed
  • utbot-framework/src/main/kotlin/org/utbot/engine

1 file changed

+8
-1
lines changed

utbot-framework/src/main/kotlin/org/utbot/engine/Resolver.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,14 @@ class Resolver(
647647

648648
val declaringClass = classLoader.loadClass(sootClass.name.substringBeforeLast("\$lambda"))
649649

650-
// TODO: add comments describing the format of Soot class name for lambdas, because here we transform it into the actual synthetic method name
650+
// Java compiles lambdas into synthetic methods with specific names.
651+
// However, Soot represents lambdas as classes.
652+
// Names of these classes are the modified names of these synthetic methods.
653+
// Specifically, Soot replaces some `$` signs by `_`, adds two underscores and some number
654+
// to the end of the synthetic method name to form the name of a SootClass for lambda.
655+
// For example, given a synthetic method `lambda$foo$1` (lambda declared in method `foo` of class `org.utbot.MyClass`),
656+
// Soot will treat this lambda as a class named `org.utbot.MyClass$lambda_foo_1__5` (the last number is probably arbitrary, it's not important).
657+
// Here we obtain the synthetic method name of lambda from the name of its SootClass.
651658
val lambdaName = sootClass.name
652659
.let { name ->
653660
val start = name.lastIndexOf("\$lambda") + 1

0 commit comments

Comments
 (0)