louiscad
04/15/2017, 7:32 PMsynchronized(this) {...}, the synchronized block is empty in the java code decompiled-from-kotlin-bytecode, and all the code that should be inside the synchronized block is below, outside of the synchronized block.
I am afraid about issues that may be caused by this… or maybe this is only a bug when decompiling bytecode from the kotlin bytecode tool?
You can try this with the following code:
object Test {
fun test() {
Unit
synchronized(this) { Unit }
}
}
you then just have to do cmd+shift+A -> kotlin bytecode, and click decompile to see it generate this:
public final class Test {
public static final Test INSTANCE;
public final void test() {
synchronized(this){}
try {
Unit var3 = Unit.INSTANCE;
} finally {
;
}
}
private Test() {
INSTANCE = (Test)this;
}
static {
new Test();
}
}
As you can see in java code on the first line of the test() method, the synchronized block is empty, and the actual code is put after it's closed…
I'm using Android Studio 2.3.1 with Kotlin 1.1.1
EDIT: Filed an issue here: https://youtrack.jetbrains.com/issue/KT-17432