LitePal
LitePal copied to clipboard
kotlin code decompile to java is error
the follow kotlin code
abstract class A {
abstract val hello: String
init {
println(hello)
}
}
class B : A() {
override val hello: String = "hello"
}
fun main() {
B()
}
the result is "null".
then, decomplie to java code is :
public final class TestKt {
public static final void main() {
new B();
}
public static void main(String[] var0) {
main();
}
}
public abstract class A {
@NotNull
public abstract String getHello();
public A() {
String var1 = this.getHello();
boolean var2 = false;
System.out.println(var1);
}
}
public final class B extends A {
@NotNull
private final String hello = "hello";
@NotNull
public String getHello() {
return this.hello;
}
}
paste the java code to new file and run it, but the result is "hello"!
who can tell me why?