Lambda initial and decompiler to java


#1

when i declare a propperty in a class like following:
class xx{
var a:()->Boolean={false}
}

and then decompiler as following:

public xxx() {
this.b = (Function0)null.INSTANCE;
}


what does the (Function0)null.INSTANCE stands for?
i think it will be :this.b= new Function0() {
public final Object invoke() {
return false;
}
};
but not ,why?


#2

The Java decompiler is intended to decompile code produced by the Java compiler. In most cases, it can produce sensible results when decompiling Kotlin-generated bytecode, but that is not always the case. In this particular case, the decompiled code is incorrect and does not represent what is actually happening.


#3

think’s for your wonderful reply!
and can you tell me how to decompile the code correctly?


#4

I’m not aware of any decompiler that handles Kotlin-generated code better.


#5

thanks for your reply!


#6

If you just want to know what is going on, the disassembler will be able to tell you (but less accessible than a decompiler). The Kotlin plugin will even display the generated bytecode for you.