So basically, I was wondering how to interpret a string interpretation in a Java context (decompiled bytecode). At first I thought it would use StringBuffer (or StringBuilder) or String.format (), but it seems like it is doing concatenation. Is this really optimal for this and what about the row pool?
Here is my Kotlin code:
fun main(args: Array<String>) {
val age : Int = 24
var mySuperString : String = "Dato is ${age} years old!"
println(mySuperString)
}
And here is the Java code that I decompiled in * .class format:
import java.io.PrintStream;
import kotlin.Metadata;
import kotlin.jvm.internal.Intrinsics;
import org.jetbrains.annotations.NotNull;
@Metadata(mv={1, 1, 6}, bv={1, 0, 1}, k=2, d1={"\000\024\n\000\n\002\020\002\n\000\n\002\020\021\n\002\020\016\n\002\b\002\032\031\020\000\032\0020\0012\f\020\002\032\b\022\004\022\0020\0040\003 \006\002\020\005 \006\006"}, d2={"main", "", "args", "", "", "([Ljava/lang/String;)V", "KotlinProject"})
public final class MainKt
{
public static final void main(@NotNull String[] args)
{
Intrinsics.checkParameterIsNotNull(args, "args");int age = 24;
String mySuperString = "Dato is " + age + " years old!";
System.out.println(mySuperString);
}
}
Even when the line is huge and there is a lot of value, it still uses plus signs!
Is this the fastest way or why do they do it?
source
share