Skip to content

Instantly share code, notes, and snippets.

View nhoxbypass's full-sized avatar
🐧
I come from Earth

Tam H. Doan nhoxbypass

🐧
I come from Earth
View GitHub Profile
// lightsaber.kt
@file:JvmName("SaberUtils")
@file:JvmMultifileClass
package org.example
fun makeLightSaber() { /*...*/ }
@nhoxbypass
nhoxbypass / app.kt
Last active January 17, 2020 11:13
Kotlin utils package level JVM name
@file:JvmName("SaberUtils")
package org.example
fun makeLightSaber() { /*...*/ }
@nhoxbypass
nhoxbypass / AppKt.java
Last active January 16, 2020 11:55
Kotlin utils: package-level method (generated)
package org.example
// Generated class
class AppKt {
public static void makeLightSaber() { /*..*/ }
}
@nhoxbypass
nhoxbypass / app.kt
Last active January 16, 2020 11:54
Kotlin utils: package-level method
package org.example
fun makeLightSaber() { /*...*/ }
// Generated class
public final class SaberFactory {
public static final SaberFactory INSTANCE = new SaberFactory();
private SaberFactory() { }
public final void makeLightSaber() { /*...*/ }
}
object SaberFactory {
fun makeLightSaber() { /*...*/ }
}
class SaberFactory {
fun makeLightSaber() { /*...*/ }
}
class Saber(val powers: Int) {
companion object Factory {
fun makeLightSaber(powers: Int): LightSaber {
return LightSaber(powers)
}
}
}
object SaberFactory {
fun makeLightSaber(powers: Int): LightSaber {
return LightSaber(powers)
}
}
Dalvik VM ART
JIT compilation Ahead-of-time (AOT) and just-in-time (JIT) compilation (Android 7.0) with code profiling
No extra installation time and storage space Take time and storage space to translate .dex file during install
Use dex opt to convert .dex bytecode to .odex bytecode Use dex2oat to generate .oat native code from .dex bytecode
JIT AOT
Dynamic translate part of bytecode to machine code and cache in memory when app run Statically translate bytecode to machine code at installation time and store in storage
Small memory One time event. Code execute faster but need extra space and time