Underling hidden costs of using JvmStatic in kotlin.
Consider we have a class A in kotlin, and we use static factory pattern to getInstance of class A.
Now the only reason we @JvmStatic is when we have inter-op from java, where an instance of class A is called from java. Let’s look into underlying java code thats generated when we use @JvmStatic for class A
Please note there is an extra method getInstance in the outer class A.
Now when we use it without @JvmStatic following code gets generated.
Notice the absence of the getInstance in the outer class. In case we don’t use @JvmStatic from java getting instance of class A would be with one extra Companion as shown below.
Now given the limitation of only 65,536 method counts in a single dex (for android), using @JvmStatic just to reduce Companion keyword is costly affair in Android.