Description
Description
Engine currently does not support the dynamicinvoke
bytecode instruction introduced in JDK 7.
An important case where invokedynamic
is necessary is string concatenation: starting from Java 9, the operator +
for String
is implemented using dynamicinvoke
. As a result, the plugin fails to generate tests for string concatenation when the code is compiled using JDK 9 or later (the primary concern is JDK 11).
To support +
operator for String
in Java 11, a fallback implementation has been provided that triggers concrete execution every time invokedynamic
is encountered (PR . It is clearly a hack, and a proper implementation of invokedynamic
is necessary.
Soot sometimes replaces invokedynamic with other invoke* opcodes (e.g., for lambdas), but it is supposedly a special case. For example, the Jimple graph for string concatenation with +
includes JDynamicInvokeExpr
expression.
Expected behavior
The implementation of invokedynamic
instruction in the engine should update the global graph with the graph of the bootstrap method and generate branches corresponding to possible outcomes of invokedynamic
along with type and/or value constraints to discard unnecessary paths.
Environment
The invokedynamic
instruction is present in JDK 7 or later.
The feature does not depend on any specific UnitTestBot configuration.
Potential alternatives
Possible approaches to support dynamicinvoke
are under investigation.
Context
- The paper that describes
invokedynamic
representation in Soot: bodden12invokedynamic.pdf - JVM spec (JDK 7), chapter 6
- Documentation for
java.lang.invoke
(JDK 11)