Skip to content

Instantly share code, notes, and snippets.

.gradle
.idea/
*.iml
build/
/local.properties
/app/build
*.apk
.DS_Store
/captures
abstract class PrefDelegate<T>(val prefKey: String) {
companion object {
private var context: Context? = null
/**
* Initialize PrefDelegate with a Context reference
* This method needs to be called before any other usage of PrefDelegate
*/
fun init(context: Context) {
class Foo {
val number
get() = if (isValid) 1 else 0
val product = number * 2
val isValid = true
}
public final class Foo {
private final int product = this.getNumber() * 2;
private final boolean isValid = true;
public final int getNumber() {
return this.isValid ? 1 : 0;
}
public final int getProduct() {
return this.product;
class Bar {
val `is valid` = true
val is_valid = true
}
public final class Bar {
private final boolean is valid = true;
private final boolean is_valid = true;
public final boolean is_valid/* $FF was: is valid*/() {
return this.is valid;
}
public final boolean is_valid() {
return this.is_valid;
Compiled from "Bar.kt"
public final class Bar {
public final boolean is valid();
Code:
0: aload_0
1: getfield #10 // Field "is valid":Z
4: ireturn
public final boolean is_valid();
Code:
$ javac Foo.java
$ javap -c Foo > bytecode_java.txt
$ kotlinc Foo.kt
$ javap -c Foo > bytecode_kotlin.txt
Compiled from "Foo.java"
public final class Foo {
public final int getNumber();
Code:
0: aload_0
1: invokevirtual #5 // Method java/lang/Object.getClass:()Ljava/lang/Class;
4: pop
5: iconst_1
6: ireturn