Kotlin, designed by JetBrains, is an open-source programming language. It is mainly used to develop Android mobile apps. Kotlin is fully compatible with Java.
To stay up to date, Kotlin updated and fixed the issues in Kotlin 1.5.0. Kotlin 1.5.20 is now released, and shows improvements in Java features and support.
The following are some of the updates and fixes in Kotlin 1.5.20.
The improvements include:
invokedynamic
.Kotlin has extended the use of dynamic invocations, invokedynamic
, in order to take advantage of the latest JVM features. Default support for compilation of SAM adapters was a feature of Kotlin 1.5.0. The feature was unbroken for string concatenation and lambdas experiments.
Additionally, compilation string concatenation to dynamic invocations is still set as a default in Kotlin 1.5.20.
invokedynamic
The main idea of invokedynamic
is a more dynamic implementation. Without changing the bytecode, it makes it possible to change the concatenation approach. It offers optimization without recompilation.
Listed below are some other advantages of bytecode for invokedynamic
.
invokedynamic
String concatenation was implemented by StringBuilder before invokedynamic
.
However, string concatenation can now be performed through the use of invokedynamic
.
For example, to concatenate a constant string with a variable before invokedynamic
, we would write the following code.
"educative" + ThreadLocalRandom.current().nextInt();
invokedynamic
Now, string concatenation can be performed via invokedynamic.
The invokedynamic
instruction clarifies and possibly improves implementations of compilers and runtime systems for dynamic languages on the JVM. To perform this, the invokedynamic
instruction permits the language implementer to outline custom linkage behavior.
Each incidence of an invokedynamic
command is called a dynamic call site.
A dynamic call site is formerly in an unlinked state, which means that there is no method specified for the call site to invoke.
A dynamic call site is joined to a technique via the bootstrap method.
The bootstrap methodology for a dynamic call site is specified by the compiler for the dynamically-typed language that is referred once by the JVM to link the location.
The call site’s behavior can be determined by the object returned from the bootstrap method.
invokedynamic
The following are the steps to invoke a dynamically linked method with the invokedynamic
.
invokedynamic
instruction.